B
brotherescott
I am trying to write a macro that will go through the entire document
and highlight the text that is entered into a input box. I can get it
to work but I am having problems with the looping and how to stop it.
What can I trigger off of to say that the selection has reached the end
of the document and stop?
Here is what I have for code so far.
Thanks for any and all help.
Sub HighLightText()
Lookup = "scott" 'Word to highlight. It will be from a input box
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.StartIsActive = False
Do
With Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Execute FindText:=Lookup
Selection.Range.HighlightColorIndex = wdYellow
End With
Loop While Selection.Find.Found <> False
End Sub
and highlight the text that is entered into a input box. I can get it
to work but I am having problems with the looping and how to stop it.
What can I trigger off of to say that the selection has reached the end
of the document and stop?
Here is what I have for code so far.
Thanks for any and all help.
Sub HighLightText()
Lookup = "scott" 'Word to highlight. It will be from a input box
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.StartIsActive = False
Do
With Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Execute FindText:=Lookup
Selection.Range.HighlightColorIndex = wdYellow
End With
Loop While Selection.Find.Found <> False
End Sub