Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Wiley Wiley is offline
external usenet poster
 
Posts: 21
Default Need a macro to put borders around every occurrence of a word

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.

  #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.



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Wiley Wiley is offline
external usenet poster
 
Posts: 21
Default Need a macro to put borders around every occurrence of a word

I knew it was simple. I am much better with Excel VBA. This is my first
attempt at Word VBA. You saved me many hours. Thanks.

"Jay Freedman" wrote:

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.




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting WordPerfect 12 files to Word 2003 Curious New Users 4 May 19th 23 02:48 PM
I am having difficulty with deleting headers and footers LHD New Users 5 July 24th 06 01:44 AM
glossary macro in Word? Tipuana Microsoft Word Help 7 June 10th 06 07:06 PM
hard space between words. Sandy L Microsoft Word Help 7 May 5th 06 08:25 PM
Word should allow to 'divide' page by 3 or 4, not just 2 CandasK Page Layout 2 February 28th 06 10:16 PM


All times are GMT +1. The time now is 06:12 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"