Share via


Bookmark Object

Bookmarks
Bookmark
Range

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

Parent Objects

Child Objects | Range Object

See Also | Bookmarks Property | Predefined Bookmarks