PreviousBookmarkID Property
TOC
Collapse the table of content
Expand the table of content

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)

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.

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

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 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);
}
Return to top
Show:
© 2016 Microsoft