MS Word VBA - remove comments and associated replies from specific Contact RRS feed

  • Question

  • Hi,

    I am trying to work out a way to delete all comments, except those from a specific person and the replies associated with their comments.

    I think the answer lies within the Ancestor property, but am unable to make this work.

    Can anyone recommend a way to identify when a comment (Child) is a reply to a comment (Parent) and return the Contact properties of the Parent comment?



    • Edited by Lordy80 Wednesday, December 14, 2016 8:15 AM
    Wednesday, December 14, 2016 8:14 AM

All replies

  • Hi,

    You could test with the code below. It could delete other comments except the specific author and its child comments.

    Sub listCom()
    Dim com As Comment
    For Each com In ActiveDocument.Comments
    Debug.Print com.Contact
    If com.Ancestor Is Nothing Then
    Debug.Print "A single comment by "; com.Contact
    If com.Contact <> "The specific author" Then
    End If
    Debug.Print "Its parents is "; com.Ancestor.Contact
    End If
    End Sub



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, December 15, 2016 11:38 AM