使用 VBA 从 PPT 幻灯片中提取所有评论

Extracting All Comments from PPT Slide using VBA

我在研究过程中发现了以下 link、

Extracting comments from a PowerPoint presentation using VBA

下面是针对同一类型问题提供的解决方案。

Sub ConvertComments()
''# Converts new-style comments to old

    Dim oSl As Slide
    Dim oSlides As Slides
    Dim oCom As Comment
    Dim oShape As Shape


    Open "filename.txt" For Output As 1
    Set oSlides = ActivePresentation.Slides

    Dim myContext As String
    For Each oSl In oSlides
        For Each oCom In oSl.Comments
            myContext = ""
            For ShapeIndex = oCom.Parent.Shapes.Count To 1 Step -1
                myContext = myContext & oCom.Parent.Shapes(ShapeIndex).AlternativeText & " "
            Next
            Write #1, oCom.Author & ";" & myContext & ";" & oCom.Text
        Next oCom
    Next oSl
    Close 1
End Sub

我发现这个脚本没有获取幻灯片中的回复评论,它只从幻灯片中获取主要评论,我也尝试更新这个解决方案以获取幻灯片中的所有评论,不幸的是我不能找到解决方案。

下面的示例将显示幻灯片 1 及其下方的每条评论、对该评论的回复数量、每条回复的作者和文本:

Sub Example()

    Dim oCom As Comment
    Dim x As Long

    For Each oCom In ActivePresentation.Slides(1).Comments
        With oCom
            Debug.Print .Author & vbCrLf & vbTab & .Text
            Debug.Print .Replies.Count
            For x = 1 To .Replies.Count
                With .Replies(x)
                    Debug.Print vbTab & .Author & vbTab & .Text
                End With
            Next
        End With
    Next

End Sub

这在 2016 年有效;我不确定 2013 年,我知道它不会在 2010 年(及更早)工作,因为它无法输入对评论的回复。 2016 年输入的回复被转换为多条评论。