DocumentBase.Words 属性

获取一个 Microsoft.Office.Interop.Word.Words 集合,该集合表示文档中的所有单词。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word.v4.0.Utilities(在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

语法

声明
Public ReadOnly Property Words As Words
public Words Words { get; }

属性值

类型:Microsoft.Office.Interop.Word.Words
一个 Microsoft.Office.Interop.Word.Words 集合,表示文档中的所有单词。

备注

文档中的标点符号和段落标记包含在 Microsoft.Office.Interop.Word.Words 集合中。

示例

下面的代码示例向该文档添加一行文本,然后使用 Words 属性将文档中第一个单词的颜色设置为蓝色。 若要使用此示例,请从文档级项目内的 ThisDocument 类中运行此示例。

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 安全性

请参见

参考

DocumentBase 类

Microsoft.Office.Tools.Word 命名空间