Partager via


How to: Programmatically remove all comments from documents

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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

Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Word. For more information, see Features available by Office application and project type.

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

  1. Call the DeleteAllComments method of the ThisDocument class in your project. To use this code example, run it from the ThisDocument class.

    Me.DeleteAllComments()
    
    this.DeleteAllComments();
    

To remove all comments from a document by using a VSTO Add-in

  1. Call the DeleteAllComments method of the 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.

    Me.Application.ActiveDocument.DeleteAllComments()
    
    this.Application.ActiveDocument.DeleteAllComments();
    

See also