Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to create a Macro for Bookmarking and Highlighting

Status
Not open for further replies.

sugermama

Technical User
Oct 19, 2001
11
US
I am using MS Word 2000. I have a 300 + page document that is updated monthly and the file is replaced. My customer has to go through the document and set bookmarks (an external ppt slide links to these bookmarks) and highlight the text, which includes the bookmark and other information on one line, in yellow. The bookmarks are always set on the same text. My question is: Is it possible to create a macro that he can run when he replaces the document that will automatically set the bookmarks and highlight the text that includes the bookmark title and the short line of text after it?
 
The following is just a minor example, and does not hilight the text after the "search" text. This can also be done, but I leave that for you to do some reasearch and try other things. Do comeback to us if you are stuck.

The following searchs for text "fred", from the active position on the document, and for each found until the end of the document it will add a bookmark and change the color of "fred" to wdColorBrightGreen


Sub aa()

Dim s
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "fred"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
s = True
While s = True
s = Selection.Find.Execute
If s Then
ActiveDocument.Bookmarks.Add Name:="bookname", Range:=Selection.Range
With Selection.Font
.Color = wdColorBrightGreen
End With
End If
Wend
End Sub




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top