Udostępnij za pośrednictwem


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)

Syntax

'Declaration
Public ReadOnly Property Words As Words
    Get
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.

Remarks

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

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 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 
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;
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace