Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Word Solutions
 How to: Remove All Comments from Do...
Collapse All/Expand All Collapse All
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: Remove All Comments from Documents

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.

Use the DeleteAllComments method to remove all comments from a Microsoft Office Word document.

To remove all comments from a document that is part of a document-level customization

To remove all comments from a document by using an application-level add-in

  • Call the DeleteAllComments method of the Microsoft.Office.Interop.Word..::.Document from which you want to remove comments.

    The following code example removes all comments from the active document. To use this code example, run it from the ThisAddIn class in your project.

    Visual Basic
    Me.Application.ActiveDocument.DeleteAllComments()
    
    C#
    this.Application.ActiveDocument.DeleteAllComments();
    
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Avoid exceptions      GaboG   |   Edit   |   Show History

Keep in mind that you will get an exception if you try to call DeleteAllComments() on a document that doesn't have any comments so it is good to wrap the call in a Globals.ThisDocument.Comments.Count > 0 check, for example:

     if (Globals.ThisDocument.Comments.Count > 0)
{
Globals.ThisDocument.DeleteAllComments();
}
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker