更新:2007 年 11 月
适用对象 |
---|
本主题中的信息仅适用于指定的 Visual Studio Tools for Office 项目和 Microsoft Office 版本。 项目类型
Microsoft Office 版本
有关更多信息,请参见按应用程序和项目类型提供的功能。 |
使用 Document 类的 Comments 属性可以向 Microsoft Office Word 文档中的文本范围添加注释。
下面的示例向文档中的第一个段落添加注释。
向文档级自定义项中的文本添加新注释
调用 Comments 属性的 Add 方法,并提供一个范围和相应的注释文本。若要使用下面的代码示例,请从项目内的 ThisDocument 类中运行此示例。
Me.Comments.Add(Me.Paragraphs(1).Range, "Add a comment to the first paragraph.")
object text = "Add a comment to the first paragraph."; this.Comments.Add(this.Paragraphs[1].Range, ref text);
向应用程序级外接程序中的文本添加新注释
调用 Comments 属性的 Add 方法,并提供一个范围和相应的注释文本。
下面的代码示例向活动文档添加注释。若要使用此示例,请从项目内的 ThisAddIn 类中运行此示例。
Me.Application.ActiveDocument.Comments.Add( _ Me.Application.ActiveDocument.Paragraphs(1).Range, _ "Add a comment to the first paragraph.")
object text = "Add a comment to the first paragraph."; this.Application.ActiveDocument.Comments.Add( this.Application.ActiveDocument.Paragraphs[1].Range, ref text);