DocumentBase.Bookmarks Property

Gets a Microsoft.Office.Interop.Word.Bookmarks collection that represents all the bookmarks in the document.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property Bookmarks As Bookmarks
public Bookmarks Bookmarks { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Bookmarks
A Microsoft.Office.Interop.Word.Bookmarks collection that represents all the bookmarks in the document.

Examples

The following code example adds a Bookmark control to the first paragraph and then displays a message that shows the total number of bookmarks in the document. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub DocumentBookmarks()
    Me.Paragraphs(1).Range.InsertParagraphAfter()
    Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "bookmark1")
    MessageBox.Show("Total number of bookmarks: " & Me.Bookmarks.Count.ToString())
End Sub
private void DocumentBookmarks()
{
    this.Paragraphs[1].Range.InsertParagraphAfter();
    this.Controls.AddBookmark(this.Paragraphs[1].Range, "bookmark1");
    MessageBox.Show("Total number of bookmarks: " + this.Bookmarks.Count.ToString());
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace