DocumentBase.Sentences 属性

定义

获取一个 Sentences 集合,该集合表示文档中的所有句子。

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

属性值

Sentences

一个 Sentences 集合,表示文档中的所有句子。

示例

下面的代码示例将两个句子添加到文档中,然后显示一条消息,其中显示文档中的句子数。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

private void DocumentSentences()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Text = "This is sample text." +
        " There are two sentences in this document.";

    MessageBox.Show("Total sentences: " + 
        this.Sentences.Count.ToString());
}
Private Sub DocumentSentences()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Text = "This is sample text." & _
        " There are two sentences in this document."
    MessageBox.Show("Total sentences: " & Me.Sentences.Count.ToString())
End Sub 

适用于