Share via


Bookmarks.Add Method

Word Developer Reference

Returns a Bookmark object that represents a bookmark added to a range.

Syntax

expression.Add(Name, Range)

expression   Required. A variable that represents a Bookmarks collection.

Parameters

Name Required/Optional Data Type Description
Name Required String The name of the bookmark. The name cannot be more than one word.
Range Optional Variant The range of text marked by the bookmark. A bookmark can be set to a collapsed range (the insertion point).

Return Value
Bookmark

Example

This example adds a bookmark named myplace to the selection in the active document.

Visual Basic for Applications
  Sub BMark()
    '  Select some text in the active document prior
    '  to execution.
    ActiveDocument.Bookmarks.Add _
        Name:="myplace", Range:=Selection.Range
End Sub

This example adds a bookmark named mark at the insertion point.

Visual Basic for Applications
  Sub Mark()
    ActiveDocument.Bookmarks.Add Name:="mark"
End Sub

This example adds a bookmark named third_para to the third paragraph in Letter.doc, and then it displays all the bookmarks for the document in the active window.

Visual Basic for Applications
  Sub ThirdPara()
    Dim myDoc As Document
'  To best illustrate this example,
'  Letter.doc must be opened, not active,
'  and contain more than 3 paragraphs.
Set myDoc = Documents("Letter.doc")
myDoc.Bookmarks.<strong class="bterm">Add</strong> Name:="third_para", _
    Range:=myDoc.Paragraphs(3).Range
myDoc.ActiveWindow.View.ShowBookmarks = True

End Sub

See Also