评论对象的祖先

发布于 2025-01-15 22:33:27 字数 386 浏览 3 评论 0原文

我想使用VBA找到指定注释对象的祖先并编写了代码。

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

但它给了我错误,因为

我正在 Word VBA 中尝试未设置对象变量(错误 91)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自我难过 2025-01-22 22:33:27

您必须检查 oComment.Ancestor 是什么都没有,因为 Ancestor 是一个对象

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文