Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Word Solutions
 How to: Add Comments to Text in Doc...
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0)
How to: Add Comments to Text in Documents

Updated: November 2007

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

  • Application-level projects

Microsoft Office version

  • Word 2003

  • Word 2007

For more information, see Features Available by Application and Project Type.

The Comments property of the Document class adds a comment to a range of text in a Microsoft Office Word document.

The following example adds a comment to the first paragraph in the document.

To add a new comment to text in a document-level customization

  • Call the Add(Range, Object%) method of the Comments property and supply a range and the comment text. To use the following code example, run it from the ThisDocument class in your project.

    Visual Basic
    Me.Comments.Add(Me.Paragraphs(1).Range, "Add a comment to the first paragraph.")
    
    
    C#
    object text = "Add a comment to the first paragraph.";
    this.Comments.Add(this.Paragraphs[1].Range, ref text);
    
    

To add a new comment to text in an application-level add-in

  • Call the Add(Range, Object%) method of the Comments()()() property and supply a range and the comment text.

    The following code example adds a comment to the active document. To use this example, run it from the ThisAddIn class in your project.

    Visual Basic
    Me.Application.ActiveDocument.Comments.Add( _
        Me.Application.ActiveDocument.Paragraphs(1).Range, _
        "Add a comment to the first paragraph.")
    
    
    C#
    object text = "Add a comment to the first paragraph.";
    this.Application.ActiveDocument.Comments.Add(
        this.Application.ActiveDocument.Paragraphs[1].Range, ref text);
    
    
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker