Extracting comments from a PowerPoint presentation using VBA

这一生的挚爱 提交于 2019-12-19 03:25:17

问题


I have a PowerPoint which contains around 50 slides. Each slide might have 1 or more comments provided by the reviwer (done using insert->comment menu).

I am trying to get the comments programatically exported into a text file using this VBA code:

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

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

        Set oSlides = ActivePresentation.Slides
        For Each oSl In oSlides
            For Each oCom In oSl.Comments
                ''# write the text to file : (oCom.Text)
                WriteToATextFile oCom.Author, <what needs to come here>, oCom.Text
            Next oCom
        Next oSl
End Sub

In the above code, I need to provide the comment context as well to be written to a text file (which line in the slide was selected and commented upon)

Question: Is there any attribute I can use to get this info?


回答1:


Like this:

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

The main part is about the loop thru all shapes parent to the comment.



来源:https://stackoverflow.com/questions/3342902/extracting-comments-from-a-powerpoint-presentation-using-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!