vbams-wordcommentsancestor

Ancestor of a comment object


I wanted to find the ancestor of a specified comment object using VBA and have written the code.

Dim oComment as Comment
Set oComment = ActiveDocument.Comments.Item(1)
If (oComment.Ancestor = Null) Then
MsgBox (ActiveDocument.Comments(1).Contact & " has added a new comment")
Else
MsgBox (ActiveDocument.Comments(1).Contact & " has replied to a comment")
End If

But it is giving me the error as Object variable not set (Error 91)

I am trying in Word VBA


Solution

  • You have to check for oComment.Ancestor is nothing as Ancestor is an object