Bulk Delete Comments with a Specific Phrase

R

Refresher

Hello,
I have 1000 comments in a word document with a specific phrase in it, say
"AAA". I want to delete all of those in bulk without deleting the rest of the
comments. Is there a way to do this?
Thanks.
 
S

Suzanne S. Barnhill

If these are comments by a specific reviewer, you can display the markup of
just that reviewer and use Delete All Comments Shown.
 
J

Jay Freedman

As often happens when you want to do something slightly unusual, you need a
macro:

Sub DeleteSomeComments()
Dim oCm As Comment
Dim strPhrase As String

strPhrase = InputBox( _
"What phrase signals a comment to delete?", _
"Delete comments containing a phrase")
If Len(strPhrase) = 0 Then Exit Sub

For Each oCm In ActiveDocument.Comments
If InStr(LCase(oCm.Range.Text), LCase(strPhrase)) Then
oCm.Delete
End If
Next
End Sub

See http://www.gmayor.com/installing_macro.htm if needed.

The comparison in this macro is not case-sensitive -- for example, if you
enter aaa, then the macro will delete comments containing AAA, AaA, aAa, and
so forth. If you want it to be case-sensitive, remove the word LCase from
the two places it occurs in the code.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
R

Refresher

Thank you Jay!

Jay Freedman said:
As often happens when you want to do something slightly unusual, you need a
macro:

Sub DeleteSomeComments()
Dim oCm As Comment
Dim strPhrase As String

strPhrase = InputBox( _
"What phrase signals a comment to delete?", _
"Delete comments containing a phrase")
If Len(strPhrase) = 0 Then Exit Sub

For Each oCm In ActiveDocument.Comments
If InStr(LCase(oCm.Range.Text), LCase(strPhrase)) Then
oCm.Delete
End If
Next
End Sub

See http://www.gmayor.com/installing_macro.htm if needed.

The comparison in this macro is not case-sensitive -- for example, if you
enter aaa, then the macro will delete comments containing AAA, AaA, aAa, and
so forth. If you want it to be case-sensitive, remove the word LCase from
the two places it occurs in the code.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top