Bookmark Object
Word Developer Reference |
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).
Remarks
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.
Visual Basic for Applications |
---|
|
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.
Visual Basic for Applications |
---|
|
Use the Add method to add a bookmark to a document range. The following example marks the selection by adding a bookmark named "temp."
Visual Basic for Applications |
---|
|
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.
Visual Basic for Applications |
---|
|
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".
Visual Basic for Applications |
---|
|
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.
Visual Basic for Applications |
---|
|
See Also