views:

35

answers:

1

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?

+2  A: 

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.

Jürgen Hollfelder
great and it worked!thanks
balalakshmi