Partilhar via


Bookmark.InStory Method

Determines if the Bookmark control to which this method is applied is in the same story as the range specified by the Range argument.

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

Syntax

'Declaration
Function InStory ( _
    Range As Range _
) As Boolean
bool InStory(
    Range Range
)

Parameters

Return Value

Type: System.Boolean
true if the Bookmark control to which this method is applied is in the same story as the range specified by the Range argument; otherwise, false.

Examples

The following code example adds a Bookmark control with text to the document and then checks to find out whether or not it is in the same story as the first paragraph. The results are then displayed in a message box.

This example is for a document-level customization.

Private Sub BookmarkInStory()
    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." 

    If Bookmark1.InStory(Me.Paragraphs(1).Range) Then
        MessageBox.Show("The bookmark is in the same story as " _
            & "the first paragraph.")
    Else
        MessageBox.Show("The bookmark is not in the same story " _
            & "as the first paragraph.")
    End If 

End Sub
private void BookmarkInStory()
{
    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.";

    if (bookmark1.InStory(this.Paragraphs[1].Range))
    {
        MessageBox.Show("The bookmark is in the same story as "+
            "the first paragraph.");
    }
    else
    {
        MessageBox.Show("The bookmark is not in the same story " +
            "as the first paragraph.");
    }
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace