Bookmark.NextStoryRange Property

Definition

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

C#
public Microsoft.Office.Interop.Word.Range NextStoryRange { get; }

Property Value

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

Examples

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.

C#
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";
}

Remarks

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.

Applies to

Product Versions
Visual Studio Tools for Office 2017, 2019, 2022