Comment 对象

         
Comments
Comment

代表给定幻灯片或幻灯片范围的批注。Comment 对象是 Comments 集合对象的成员。

使用 Comment 对象

使用 Comments(index)(其中 index 为批注的编号)或 Item 方法访问幻灯片上的单个批注。本示例显示第一张幻灯片上第一个批注的作者。如果没有批注,将显示一条消息进行声明。

Sub ShowComment()
    With ActivePresentation.Slides(1).Comments
        If .Count > 0 Then
            MsgBox "The first comment on this slide is by " & _
                .Item(1).Author
        Else
            MsgBox "There are no comments on this slide."
        End If
    End With
End Sub

使用以下属性访问批注数据:

Author 作者的全名
AuthorIndex 作者在批注列表中的索引
AuthorInitials 作者姓和名的首字母
DateTime 创建批注的日期和时间
Text 批注的文本
LeftTop 批注的屏幕坐标

本示例显示一条消息,其中包含第一张幻灯片上所有批注的作者、日期、时间和内容。

Sub SlideComments()
    Dim cmtExisting As Comment
    Dim cmtAll As Comments
    Dim strComments As String

    Set cmtAll = ActivePresentation.Slides(1).Comments

    If cmtAll.Count > 0 Then
        For Each cmtExisting In cmtAll
            strComments = strComments & cmtExisting.Author & vbTab & _
                cmtExisting.DateTime & vbTab & cmtExisting.Text & vbLf
        Next
        MsgBox "The comments in your document are as follows:" & vbLf _
            & strComments
    Else
        MsgBox "This slide doesn't have any comments."
    End If
End Sub