Expand Minimize
This topic has not yet been rated - Rate this topic

DocumentBase.Words Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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;
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.