DocumentBase.Comments 属性

定义

获取一个 Comments 集合,该集合表示文档中的所有注释。

public Microsoft.Office.Interop.Word.Comments Comments { get; }

属性值

Comments

一个 Comments 集合,表示文档中的所有注释。

示例

下面的代码示例向第一个段落添加文本,然后向段落中的第二个单词添加注释。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

private void DocumentComments()
{
    this.Paragraphs[1].Range.InsertParagraphAfter();
    this.Paragraphs[1].Range.Text = "This is sample Text";
    object commentText = "This is comment text";
    this.Comments.Add(this.Paragraphs[1].Range.Words[2], ref commentText);
}
Private Sub DocumentComments()
    Me.Paragraphs(1).Range.InsertParagraphAfter()
    Me.Paragraphs(1).Range.Text = "This is sample Text"
    Dim commentText As Object = "This is comment text"
    Me.Comments.Add(Me.Paragraphs(1).Range.Words(2), commentText)
End Sub

适用于