Consulting

Results 1 to 2 of 2

Thread: Delete Comments in Word Document if Applicable

  1. #1

    Delete Comments in Word Document if Applicable

    Hi,

    I have a VBA to except revisions and delete comments in a word document. However, how do I indicate if there is no comments then to move on?

    Here's a sample:

    objDocx.AcceptAllRevisions
    objDocx.DeleteAllComments
    objDocx.Save

    So if there is no comments I get an error, so I'm not sure what's the next 'wordings' to indicate if applicable.

    Currently I created the VBA so I can select the document, so if you have a code to do this with documents in a folder without it opening and performing the action that would be great.

    Thank you.

  2. #2
    Count the comments first e.g.

    If objDocx.Comments.Count > 0 Then objDocx.DeleteAllComments
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •