Sivaprasad Km
Sivaprasad Km

Reputation: 730

Extracting All Comments from PPT Slide using VBA

During the research I found below link,

Extracting comments from a PowerPoint presentation using VBA

Below is the solution provided in for thissame type of question.

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

I found that this script not fetching the reply comments in the slides, Its only fetching the main comments from the slides, I also tried to update this solution to get all comments from the slide, bad luck I couldn't find the solution.

Upvotes: 1

Views: 1126

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

Here's an example that will show each comment on slide 1 and under it, the number of replies to the comment, the author and text of each reply:

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

This works in 2016; I'm not sure of 2013 and I know it won't work in 2010 (and earlier) because it doesn't have the ability to enter replies to comments. Replies entered in 2016 get converted to multiple comments.

Upvotes: 2

Related Questions