Microsoft Office Tutorials and References
In Depth Information
Making Bookmarks Visible
'to ask the user for the name¶
'Uncomment the next two lines to use that method¶
'BookmarkName = InputBox( _¶
'No text is selected. Type in a bookmark name.")¶
Else¶
Making Bookmarks Visible
With this procedure, you can highlight bookmarks in a document and place
their names in comments to make them easier to manage.
Example file:
W039
Scenario: When setting up a document with many
bookmarks, it is often difficult to keep track of their locations
and names. One way to obtain an overview is to highlight
them, and put their names in comments.
Wrd
Tip: In Word 2002 and 2003, comments can be displayed in the right margin, with connecting
lines. In Word 97, Word 2000, and Word 2003, the bookmark name appears in tip flags
when the mouse hovers over a comment.
View the Appendix to learn how to store this procedure
in a Standard module.
Option explicit¶
' * * * * *¶
Sub HighLightBookmarks()¶
'Variable declaration¶
Dim bkm As Word.Bookmark¶
Dim rng As Word.Range¶
For Each bkm In ActiveDocument.Bookmarks¶
Set rng = bkm.Range¶
rng.HighlightColorIndex = wdYellow¶
ActiveDocument.Comments.Add _¶
Range:=rng, Text:=bkm.Name¶
Set rng = Nothing¶
Next bkm¶
End Sub¶
' * * * * *¶
Sub RemoveHighlighting()¶
If Selection.Type = wdSelectionIP Then¶
ActiveDocument.Range.HighlightColorIndex = wdNoHighlight¶
ElseIf Selection.Type = wdSelectionNormal Then¶
 
Search JabSto ::




Custom Search