DocumentBase.Words Property

 

Gets a Microsoft.Office.Interop.Word.Words collection that represents all the words in the document.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public Words Words { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Words

A Microsoft.Office.Interop.Word.Words collection that represents all the words in the document.

Punctuation and paragraph marks in a document are included in the Microsoft.Office.Interop.Word.Words collection.

The following code example adds a line of text to the document and then uses the Words property to set the color of the first word in the document to blue. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentWords()
{
    object start = 0;
    object end = 0;
    Word.Range range1 = this.Range(ref start, ref end);
    range1.Text = "This is the first sentence in the document.";

    this.Words.First.Font.Color = Word.WdColor.wdColorBlue;
}
Return to top
Show: