Share via


DocumentBase.Words Property

Definition

Gets a Words collection that represents all the words in the document.

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

Property Value

A Words collection that represents all the words in the document.

Examples

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;
}
Private Sub DocumentWords()
    Dim start As Object = 0
    Dim [end] As Object = 0
    Dim range1 As Word.Range = Me.Range(start, [end])
    range1.Text = "This is the first sentence in the document."

    Me.Words.First.Font.Color = Word.WdColor.wdColorBlue
End Sub 

Remarks

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

Applies to