View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Need a macro to put borders around every occurrence of a word

It's not unusual for the macro recorder to botch the job. See
http://www.word.mvps.org/FAQs/Macros...ordedMacro.htm.

Here's code that works:

With Selection.Find
.Text = "SYSTEM:"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute
Selection.Borders.Enable = True
Loop
End With

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


Wiley wrote:
I want to find several different words in a document, an dhighlight
them with a border (box). I have treid the following section ( with
help from the macro recorder) to do this, but get "Invlaid Use of
Propert"y error on the Borders. how do I appy the border to the
found items?

With Selection.Find
.Text = "SYSTEM:"
.Replacement.Text = "SYSTEM:"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = True
.Replacement.Font.Borders (1)
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With


Thanks.