DocumentBase.Characters 属性

定义

获取一个 Characters 集合,该集合表示文档中的字符。

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

属性值

Characters

一个 Characters 集合,表示文档中的字符。

示例

下面的代码示例向第一个段落添加文本,然后显示一个消息框,其中显示文档中的字符总数。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

private void DocumentCharacters()
{
    this.Paragraphs[1].Range.InsertParagraphAfter();
    this.Paragraphs[1].Range.Text = "This is sample text.";
    MessageBox.Show("Total characters in document: " + this.Characters.Count);
}
Private Sub DocumentCharacters()
    Me.Paragraphs(1).Range.InsertParagraphAfter()
    Me.Paragraphs(1).Range.Text = "This is sample text."
    MessageBox.Show("Total characters in document: " & Me.Characters.Count)
End Sub

适用于