DocumentBase.StoryRanges 属性

定义

获取一个 StoryRanges 集合,该集合表示文档中的所有内容。

public Microsoft.Office.Interop.Word.StoryRanges StoryRanges { get; }

属性值

StoryRanges

一个 StoryRanges 集合,表示文档中的所有内容。

示例

下面的代码示例将文本添加到文档页眉,然后显示一条显示标头文本的消息。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

private void DocumentStoryRanges()
{
    this.Sections[1].Headers[Word.WdHeaderFooterIndex.
        wdHeaderFooterPrimary].Range.Text = 
        "Header text";
    MessageBox.Show (this.StoryRanges[
        Word.WdStoryType.wdPrimaryHeaderStory].Text);

}
Private Sub DocumentStoryRanges()
    Me.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Text _
        = "Header text"
    MessageBox.Show(Me.StoryRanges(Word.WdStoryType.wdPrimaryHeaderStory).Text)
End Sub 

适用于