Bookmarks object (Word)

A collection of Bookmark objects that represent the bookmarks in the specified selection, range, or document.

Remarks

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

ActiveDocument.Bookmarks.Add Name:="temp", Range:=Selection.Range

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

Remarks

The ShowHidden property effects the number of elements in the Bookmarks collection. If ShowHidden is True, hidden bookmarks are included in the Bookmarks collection.

Methods

Properties

See also

Support and feedback

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.