View Single Post
  #16   Report Post  
Graham Mayor
 
Posts: n/a
Default

http://www.gmayor.com/installing_macro.htm may help

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Anoron wrote:
That looks as though it will be very helpful. However, I'm not
exactly sure
how to get to the code (or which file it is in). I am familiar with
script coding because I work some with HTML and Javascript, but that
is it. I'm perfectly comfortable following your instructions for
editing the script,
once I get into it. Thanks for all your help.

"Dian Chapman, MVP, MOS" wrote:

I just got a chance to check out the code and what you can do is go
into the VBA code inside the template and look for this section of
code:

'================================================= ==
Sub ColorWords(ByVal strText As String, _
ByVal MyColor As Variant)

With ActiveDocument.Content.Find
.ClearFormatting
With .Replacement
.ClearFormatting
.Font.Color = MyColor
End With
.Execute FindText:=strText, ReplaceWith:=strText, _
Format:=True, Replace:=wdReplaceAll

End With

End Sub
'================================================= ==

You can add the

.MatchWholeWord = True

....argument as Suzanne suggests and that'll give you a refine
search.
I didn't look at the article well enough before to rememeber that
Greg eventually does call a find/replace routine. So change the above
section of code so it looks like this:

'================================================= ==
Sub ColorWords(ByVal strText As String, _
ByVal MyColor As Variant)

With ActiveDocument.Content.Find
.ClearFormatting
With .Replacement
.ClearFormatting
.MatchWholeWord = True '--- this is the new line
.Font.Color = MyColor
End With
.Execute FindText:=strText, ReplaceWith:=strText, _
Format:=True, Replace:=wdReplaceAll

End With

End Sub
'================================================= ==

Have fun!

Dian D. Chapman, Technical Consultant
Microsoft MVP, MOS Certified
Editor/TechTrax Ezine

Free Tutorials: http://www.mousetrax.com/techtrax
Free Word eBook: www.mousetrax.com/books.html
Optimize your business docs: www.mousetrax.com/consulting
Learn VBA the easy way: www.mousetrax.com/techcourses.html



On Fri, 28 Jan 2005 15:13:02 -0800, ?B?QW5vcm9u?=
wrote:

That is so helpful that I am planning to mention it to the rest of
my writers guild! I do have one question though. Is there a way to
make it flag only entire words (for example it is coloring the word
"very" -- even in the word everything)? Thanks.