Find Selected Text and Format

K

Kerri

Hi,



I have used the WestCiteLink Table of Authorities feature and am trying to
create a follow-up for the users to fix some formatting issues.

I am using both Word 2000 and 2003. I am selecting the text found in the
Table of Authorities (TOA), then displaying the Find box typing a quote (")
then pasting the copied text. It would look like this: "Adams Realty Corp.
v. Realty Center Investments, Inc., . I have to add the quote so it will
find the text in the field {TA \1 "Adams Realty Corp.v...... and not the
text in the document, which doesn't have a quote.



Unfortunately, I don't know how to set the selected text to appear in the
Find box when it changes based on what is selected. I hope this makes
sense. It keeps formatting the selected text (in the TOA) and not finding
the next occurrence. This is what I have so far.

Thank you for your help, Kerri

Sub CiteLinkUpdateItalics()
ActiveWindow.ActivePane.View.ShowAll = Not ActiveWindow.ActivePane.View.
_
ShowAll
ToaText = Selection.Range
'With ToaText
' Selection.Copy
'End With
ToaText = """ & toaText 'this should be what ever text is selected in
the document

Selection.Find.ClearFormatting
With Selection.Find
.Text = ToaText 'this should be what ever text is selected in the
document.
.Replacement.Text = ""
.Forward = True
End With
Selection.Find.Execute
'Applys Italics
Selection.Font.Italic = True
Selection.MoveRight Unit:=wdCharacter, Count:=1
'Inserts Soft Return
Selection.TypeText Text:=Chr(11)
End Sub
 
K

Kerri

Hi,
I figured it out. I used a bookmark to name the selected text and then pull
that in to the Find box. I had a hard time figuring out how to get the "
quote to dispaly infront of the text...until I came accross the Chr(34) as
the symbol for quote.

If there was an easier way I'd love to know about it.
Thank you, Kerri

Sub CiteLinkUpdateItalics()

'Show the document codes
If ActiveWindow.ActivePane.View.ShowAll = False Then
ActiveWindow.ActivePane.View.ShowAll = True
End If

'Inserts a bookmark where they selected text is located
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="SelectedText"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With

orng = ActiveDocument.Bookmarks("SelectedText").Range
'Chr(34) is the quote symbol
orng = Chr(34) & orng
Selection.Find.ClearFormatting
With Selection.Find
.Text = orng
.Replacement.Text = ""
.Forward = True
End With
Selection.Find.Execute
'Applys Italics
Selection.Font.Italic = True
Selection.MoveRight Unit:=wdCharacter, Count:=1
'Inserts Soft Return
Selection.TypeText Text:=Chr(11)

'go back to TOA - find the bookmark
Selection.GoTo What:=wdGoToBookmark, Name:="SelectedText"
'Update the TOA to show the changes
Selection.Fields.Update

End Sub
 
E

Ed

Kerri - in your first code, try changing Selection.Range to Selection.Text
and see if that helps.

Ed
 
M

Mark Baird

If you are just setting a bookmark to get the text there is no need for this. You can easily use Selection.Text

Selection.Find.ClearFormattin
With Selection.Fin
.Text = Selection.Tex
.Replacement.Text = "
.Forward = Tru
End Wit
Selection.Find.Execut

Mark Bair
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top