DocumentBase.Words 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个 Words 集合,该集合表示文档中的所有单词。
public Microsoft.Office.Interop.Word.Words Words { get; }
属性值
一个 Words 集合,表示文档中的所有单词。
示例
下面的代码示例将一行文本添加到文档中,然后使用 Words 属性将文档中第一个单词的颜色设置为蓝色。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。
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
注解
文档中的标点符号和段落标记包含在集合中 Microsoft.Office.Interop.Word.Words 。