Bookmark.PreviousBookmarkID Property

Gets a value that represents the number of the last bookmark that starts before or at the same place as the Bookmark control.

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

Syntax

'Declaration
ReadOnly Property PreviousBookmarkID As Integer
int PreviousBookmarkID { get; }

Property Value

Type: System.Int32
The number of the last bookmark that starts before or at the same place as the Bookmark control.

Remarks

The PreviousBookmarkID property returns 0 (zero) if there is no corresponding bookmark.

Examples

The following code example adds a Bookmark control with text to the document and displays the name of the bookmark in a message box using the PreviousBookmarkID property.

This example is for a document-level customization.

Private Sub BookmarkPreviousBookmarkID()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
    Bookmark1.Text = "This is sample bookmark text."

    MessageBox.Show(Me.Bookmarks(Bookmark1.PreviousBookmarkID).Name)

End Sub
private void BookmarkPreviousBookmarkID()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text.";

    object bookmarkID = bookmark1.PreviousBookmarkID;
    MessageBox.Show (this.Bookmarks.get_Item(ref bookmarkID).Name);
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace