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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。