If you include the following code in a macro and replace the XXX by the
desired initials, all comments inserted by the person with the specified
initials will be deleted (the initials appear in square brackets in the
comments):
Dim oCom As Comment
If ActiveDocument.Comments.Count = 0 Then
MsgBox "No comments found."
Exit Sub
End If
For Each oCom In ActiveDocument.Comments
'Delete all comments made by person with the specified initials
If oCom.Initial = "XXX" Then
oCom.Delete
End If
Next oCom
-----------------------
To delete all comments that contain a specified string in the comment text,
you can use the following code. Replace XXX by the text you want to find:
Dim oCom As Comment
If ActiveDocument.Comments.Count = 0 Then
MsgBox "No comments found."
Exit Sub
End If
For Each oCom In ActiveDocument.Comments
'Delete all comments that include the text specified in "XXX"
If InStr(1, oCom.Range.Text, "XXX") > 0 Then
oCom.Delete
End If
Next oCom
If you need to run such macro often, you could add an InputBox that asks
about the desired initials or text string so that you do not need to change
it in the macro. Please post back if this is relevant and if you need help on
the InputBox part.
--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word