Bookmarks.Add method (Word)
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 40 characters or include 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.
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.
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.
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.Add Name:="third_para", _
Range:=myDoc.Paragraphs(3).Range
myDoc.ActiveWindow.View.ShowBookmarks = True
End Sub
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.