Charles
Wed Jun 30 18:49:00 CDT 2004
Why not use the replace method?
Sub HighlightMyText()
'
' Macro written 6/30/04 by Charles Kyle Kenyon
'
Dim strMyString As String
strMyString = InputBox( _
Prompt:="Word or phrase to highlight?"?", _
Title:= "Highlighter Macro")
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Text = strMyString
.Replacement.Text = strMyString
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
End Sub
The following recorded macro shows commands to change the highlight color
(Word 2000).
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/30/04 by Charles Kyle Kenyon
' "&chr(10)&"Changes highlight color
'
Options.DefaultHighlightColorIndex = wdBrightGreen
Options.DefaultHighlightColorIndex = wdTurquoise
Options.DefaultHighlightColorIndex = wdPink
Options.DefaultHighlightColorIndex = wdBlue
Options.DefaultHighlightColorIndex = wdRed
Options.DefaultHighlightColorIndex = wdGray50
Options.DefaultHighlightColorIndex = wdNoHighlight
End Sub
Hope this gets you on the right track. (There are more colors available but
you can record them as easily as I can.)
--
Charles Kenyon
Word New User FAQ & Web Directory:
<URL:
http://www.addbalance.com/word/index.htm>
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL:
http://www.addbalance.com/usersguide/index.htm>
Word Resources Page
<URL:
http://www.addbalance.com/word/wordwebresources.htm>
See also the MVP FAQ: <URL:
http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
"Andre Navaille" <navaille@sbcglobal.net> wrote in message
news:H0HEc.79684$C61.56871@newssvr29.news.prodigy.com...
> Basically I'm trying to create a macro that finds (ctrl-f) certain words
> throughout the entire document and highlight them different colors. The
> macro records fine but when I run it it does 1 of 3 things. 1st it may not
> highlight any words even if they are present in the search criteria. 2nd
it
> may highlight the entire document and lastly it may find the first word
and
> highlight only it. I don't currently have any virus's and never had on
this
> system. Besides I tested this on another system using word 2003 with the
> same result and I didn't use the macro I created, I started fresh. Any
> idea's or suggestions would be appreciated. This is a daily task of about
> 20 pages and up to 12 different words so any help would be wonderful.
>
> Thanks
>
>
>