Bookmarks Object (Word)
Published: July 16, 2012
A collection of Bookmark objects that represent the bookmarks in the specified selection, range, or document.
Use the Bookmarks property to return the Bookmarks collection for a document, range, or selection. The following example ensures that the bookmark named "temp" exists in the active document before selecting the bookmark.
If ActiveDocument.Bookmarks.Exists("temp") = True Then ActiveDocument.Bookmarks("temp").Select End If
Use the Add method to set a bookmark for a range in a document. The following example marks the selection by adding a bookmark named "temp".
Use Bookmarks(index), where index is the bookmark name or index number, to return a single Bookmark object. You must exactly match the spelling (but not necessarily the capitalization) of the bookmark name. The following example selects the bookmark named "temp" in the active document.
The index number represents the position of the bookmark in the Selection or Range object. For the Document object, the index number represents the position of the bookmark in the alphabetical list of bookmarks in the Bookmarks dialog box (click Name to sort the list of bookmarks alphabetically). The following example displays the name of the second bookmark in the Bookmarks collection.
The ShowHidden property effects the number of elements in the Bookmarks collection. If ShowHidden is True, hidden bookmarks are included in the Bookmarks collection.