This is something I found in Word 'help'. It'll change all
instances of what I find, but I have no luck finding the
syntax/command to highlight the hits rather than changing
them. Can you help me out?

With ActiveDocument.Content.Find
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:="employer_lname",
ReplaceWith:=" EMPLOYER_LNAME", _
Replace:=wdReplaceAll
End With

Thanks!!!

Re: How can you highlight same word through a Word document? by Jonathan

Jonathan
Wed Jun 30 14:22:34 CDT 2004


"Inter2Land" <rita.andrie@state.mn.us> wrote in message
news:23e7c01c45ece$79846450$a501280a@phx.gbl...
> This is something I found in Word 'help'. It'll change all
> instances of what I find, but I have no luck finding the
> syntax/command to highlight the hits rather than changing
> them. Can you help me out?
>
> With ActiveDocument.Content.Find
> Set myRange = ActiveDocument.Content
> myRange.Find.Execute FindText:="employer_lname",
> ReplaceWith:=" EMPLOYER_LNAME", _
> Replace:=wdReplaceAll
> End With
>
> Thanks!!!
>

Unfortunately not. Microsoft didn't made this feature programmable when it
was first introduced in Word 2002.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup


Re: How can you highlight same word through a Word document? by Jean-Guy

Jean-Guy
Wed Jun 30 21:14:59 CDT 2004

Bonjour,

Dans son message, < Inter2Land > écrivait :
In this message, < Inter2Land > wrote:

|| This is something I found in Word 'help'. It'll change all
|| instances of what I find, but I have no luck finding the
|| syntax/command to highlight the hits rather than changing
|| them. Can you help me out?
||
|| With ActiveDocument.Content.Find
|| Set myRange = ActiveDocument.Content
|| myRange.Find.Execute FindText:="employer_lname",
|| ReplaceWith:=" EMPLOYER_LNAME", _
|| Replace:=wdReplaceAll
|| End With
||

You asked about highlighting words, but the example you posted replaces
words...
Just in case, this first example replaces AND highlights, the one after just
highlights.

'_______________________________________
Dim MyRange As Range

Set MyRange = ActiveDocument.Range
With MyRange.Find
.ClearFormatting
.Forward = True
.Text = "employer_lname"
.Wrap = wdFindStop
.Replacement.Text = "EMPLOYER_LNAME"
Do While .Execute(Replace:=wdReplaceOne)
With MyRange
.HighlightColorIndex = wdYellow
.SetRange .End, ActiveDocument.Range.End
End With
Loop
End With

Set MyRange = Nothing
'_______________________________________


'_______________________________________
Dim MyRange As Range

Set MyRange = ActiveDocument.Range
With MyRange.Find
.ClearFormatting
.Forward = True
.Text = "employer_lname"
.Wrap = wdFindStop
Do While .Execute
With MyRange
.HighlightColorIndex = wdYellow
.SetRange .End, ActiveDocument.Range.End
End With
Loop
End With

Set MyRange = Nothing
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org