Tuesday, March 27, 2012

MS Word: How to delete all the comments in a document using Visual Basic for Applications (VBS)

I just got passed a document with a Microsoft Word document with a zillion comments in it.  I could have deleted all the comments by hand, but it would have taken forever and there would be a good chance I would miss one.  So I used Visual Basic for Applications to do it.  Here are the steps:

  1. In MS Word, type Alt-F11 to bring up the Macro window
  2. At the bottom of the Macro window, there is a pane labelled "Immediate".  Commands entered here are run immediately.
  3. On a single line in the immediate pane, type

    for z = ActiveDocument.Comments.Count to 1 step -1: ActiveDocument.Comments(z).Delete : next
  4. Hit Enter. All of the comments in the document will be deleted.