Udostępnij za pośrednictwem


Bookmark.PreviousBookmarkID Property

Definition

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

public:
 property int PreviousBookmarkID { int get(); };
public int PreviousBookmarkID { get; }
member this.PreviousBookmarkID : int
Public ReadOnly Property PreviousBookmarkID As Integer

Property Value

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

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

Remarks

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

Applies to