Bookmark.InStory Method (Range)

 

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)

bool InStory(
	Range Range
)

Parameters

Range
Type: Microsoft.Office.Interop.Word.Range

The Range object whose story is compared with the story that contains the Bookmark control.

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.

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 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.");
    }
}
Return to top
Show: