DocumentBase.Characters Property

Definition

Gets a Characters collection that represents the characters in the document.

public:
 property Microsoft::Office::Interop::Word::Characters ^ Characters { Microsoft::Office::Interop::Word::Characters ^ get(); };
public Microsoft.Office.Interop.Word.Characters Characters { get; }
member this.Characters : Microsoft.Office.Interop.Word.Characters
Public ReadOnly Property Characters As Characters

Property Value

A Characters collection that represents the characters in the document.

Examples

The following code example adds text to the first paragraph and then shows a message box that displays the total number of characters in the document. To use this example, run it from the ThisDocument class in a document-level project.

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

Applies to