RSS

Category Archives: MS Office

Macro to Extract Comments from a PPT to a Text File

Use the macro below to extract all the comments in a PPT file to a text file. You can then print the text file.

When you run this macro, it opens an Output File dialog box asking for a path to store the text. Remember to enter a name for the file when you specify the path in the ‘Output file’ dialog. Example: C:\Documents and Settings\User1\Desktop\comments.txt

Sub ExportComments()

    Dim oSl As Slide
    Dim oSlides As Slides
    Dim oCom As Comment
    Dim sText As String
    Dim sFilename As String

    Set oSlides = ActivePresentation.Slides
    For Each oSl In oSlides
    sText = sText & "Slide: " & oSl.SlideIndex & vbCrLf
    sText = sText & "======================================" & vbCrLf
        For Each oCom In oSl.Comments

            sText = sText & oCom.Author & vbCrLf
            sText = sText & oCom.DateTime & vbCrLf
            sText = sText & oCom.Text & vbCrLf
            sText = sText & "--------------" & vbCrLf

        Next oCom
    Next oSl

    sFilename = InputBox("Full path to output file:", "Output file")
    If Len(sFilename) > 0 Then
        WriteStringToFile sFilename, sText
        SendFileToNotePad sFilename
    End If

End Sub

Sub WriteStringToFile(pFileName As String, pString As String)
' This writes the text out to a file

    Dim intFileNum As Integer

    intFileNum = FreeFile
    Open pFileName For Output As intFileNum
    Print #intFileNum, pString
    Close intFileNum

End Sub

Sub SendFileToNotePad(pFileName As String)
' This opens the file in notepad

    Dim lngReturn As Long
    lngReturn = Shell("NOTEPAD.EXE " & pFileName, vbNormalFocus)

End Sub

Macro courtesy: pptfaq.com

 
1 Comment

Posted by on July 8, 2011 in MS Office, Tools, Utilities