Bagikan melalui


DocumentBase.Bookmarks Property

Definition

Gets a Bookmarks collection that represents all the bookmarks in the document.

public:
 property Microsoft::Office::Interop::Word::Bookmarks ^ Bookmarks { Microsoft::Office::Interop::Word::Bookmarks ^ get(); };
public Microsoft.Office.Interop.Word.Bookmarks Bookmarks { get; }
member this.Bookmarks : Microsoft.Office.Interop.Word.Bookmarks
Public ReadOnly Property Bookmarks As Bookmarks

Property Value

A 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 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());
}
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

Applies to