Bookmark object (Word)
Represents a single bookmark in a document, selection, or range. The Bookmark object is a member of the Bookmarks collection. The Bookmarks collection includes all the bookmarks listed in the Bookmark dialog box (Insert menu).
Using the Bookmark Object
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.
ActiveDocument.Bookmarks("temp").Select
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.
MsgBox ActiveDocument.Bookmarks(2).Name
Use the Add method to add a bookmark to a document range. The following example marks the selection by adding a bookmark named "temp."
ActiveDocument.Bookmarks.Add Name:="temp", Range:=Selection.Range
Remarks
Use the BookmarkID property with a range or selection object to return the index number of a Bookmark object in the Bookmarks collection. The following example displays the index number of the bookmark named "temp" in the active document.
MsgBox ActiveDocument.Bookmarks("temp").Range.BookmarkID
Use predefined bookmarkswith the Bookmarks property. The following example sets the bookmark named "currpara" to the location marked by the predefined bookmark named "\Para".
ActiveDocument.Bookmarks("\Para").Copy "currpara"
Use the Exists method to determine whether a bookmark already exists in the selection, range, or document. 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
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.