PDA

View Full Version : Delete Comments in Word Document if Applicable



Mia
12-10-2019, 04:54 PM
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.

gmayor
12-11-2019, 04:52 AM
Count the comments first e.g.


If objDocx.Comments.Count > 0 Then objDocx.DeleteAllComments