Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlighting Replaced Words

Status
Not open for further replies.

ljjtek

Technical User
Feb 26, 2001
35
US
What would be the code if I wanted to highlight certain words within a document? Like if I wanted to replace any instance of the word 'boy' with 'boy'(highlighted)?

So far, this is what I have...



Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "boy"
.Replacement.Text = "boy"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
 
Hi ljjtek,

Just add

Code:
Selection.Find.Replacement.Highlight = True
somewhere before the Find.Execute

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top