DocumentBase.Sentences 属性

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

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word.v4.0.Utilities(在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

语法

声明
Public ReadOnly Property Sentences As Sentences
public Sentences Sentences { get; }

属性值

类型:Microsoft.Office.Interop.Word.Sentences
一个 Sentences 集合,表示文档中的所有句子。

示例

下面的代码示例向文档添加两个句子,然后显示一条包含文档中句子数目的消息。 若要使用此示例,请从文档级项目内的 ThisDocument 类中运行此示例。

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 
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());
}

.NET Framework 安全性

请参见

参考

DocumentBase 类

Microsoft.Office.Tools.Word 命名空间