Search Highlight Text

M

Mark Tangard

Abhijeet,

How about this:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Wrap = wdFindStop
.Forward = True
.Format = False
.Highlight = True
.MatchCase = False
.MatchWildcards = False
Do While .Execute
If Selection.Range.HighlightColorIndex = wdBlue Then
Exit Sub
End If
Loop
End With
 
K

Klaus Linke

Unfortunately, if adjacent text is highlighted in different colors,
..Find.Execute will match it all, and .HighlightColorIndex will return
9999999 (wdUndefined).

Then you'd have to loop each character.

I don't understand why Highlight is defined differently from any other font
formatting.
It should simply be another property of the .Font object, like .Underline
(with the special value of wdHighlightNone if there is no Highlight).
Then there'd be no problem to search for different color highlights.

Probably highlighting was developed by a different department than the rest
of the formatting ;-)

Klaus
 

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