DocumentBase.Comments 属性

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

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

语法

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

属性值

类型:Microsoft.Office.Interop.Word.Comments
一个 Comments 集合,表示文档中的所有注释。

示例

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

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

.NET Framework 安全性

请参见

参考

DocumentBase 类

Microsoft.Office.Tools.Word 命名空间