Bookmark Object

Description

Represents a single bookmark. 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 alphabetic 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 the 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
You can use predefined bookmarks with 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
Properties

Application property, Column property, Creator property, Empty property, End property, Name property, Parent property, Range property, Start property, StoryType property.

Methods

Copy method, Delete method, Select method.