Bookmark.NextStoryRange Property

 

Gets a Range object that refers to the next story, as shown in the following table.

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

Range NextStoryRange { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Range

a Range object that refers to the next story, as shown in the following table.

Story type

Item returned by the NextStoryRange method

wdMainTextStory, wdFootnotesStory, wdEndnotesStory, and wdCommentsStory

Always returns null.

wdTextFrameStory

The story of the next set of linked text boxes.

wdEvenPagesHeaderStory, wdPrimaryHeaderStory, wdEvenPagesFooterStory, wdPrimaryFooterStory, wdFirstPageHeaderStory, wdFirstPageFooterStory

The story of the same type in the next section.

The following code example adds a Next page section break to the document and then adds a Bookmark control with text to the even page header of section 1. The code then uses NextStoryRange to add text to the header of section 2.

This example is for a document-level customization.

private void BookmarkNextStoryRange()
{
    int WordTrue = -1;
    object BreakType = Word.WdBreakType.wdSectionBreakNextPage;
    this.Paragraphs[1].Range.InsertBreak(ref BreakType);

    this.PageSetup.OddAndEvenPagesHeaderFooter = WordTrue;

    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Sections[1].Headers[
        Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].Range, 
        "bookmark1");
    bookmark1.Text = "Even Header 1";
    this.Sections[2].Headers[Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages] 
        .LinkToPrevious = false;

    bookmark1.NextStoryRange.Text = "Even Header 2";
}
Return to top
Show: