首页 > 解决方案 > Microsoft Word VBA 宏读取注释

问题描述

我正在尝试使用以下代码阅读文档中数字的注释

For Each iShp In .InlineShapes
  iShp.Select

  If Selection.Comments.Count > 0 Then
    MsgBox Selection.Comments(1).Range.text
  End If
Next

形状选择正确,但计数始终为 0...

我错过了什么?

标签: vbams-word

解决方案


这是阅读所有评论的另一种方法:

Option Explicit

Sub DisplayCommentText()
    With ActiveDocument
        Dim cmt As Comment
        For Each cmt In .Comments
            Debug.Print cmt.Range.Text
        Next cmt
    End With
End Sub

推荐阅读