codewala

code it

Macro to import notes from PowerPoint into Word

I needed to export only the notes from PowerPoint into Word. In PowerPoint 2003, we can use “File – send to – MS Office Word” to export the PowerPoint as Word. But faced two issues with this
1. There is no option to only export notes section
2. The bullet formatting of the notes section is lost at the time of export. This issue has been resloved in MS Office 2007.

Wrote my own macro in Word which will only import the notes section from PowerPoint into Word and also retain the bullet formatting given in PowerPoint.


'-------------------------------------------------------------
Option Explicit
'
Sub ImportNotes()

' FOR WORD
Dim oDoc As Document
Dim docPath As String
Dim oTable As Table
Dim oRow As Row
' FOR POWERPOINT
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppFileName As String
Dim ppFilePath As String
Dim oSlides As Slides
Dim oSlide As Slide
Dim oShape As Shape
'
Set oDoc = ActiveDocument
Set oTable = oDoc.Tables(1)
docPath = oDoc.Path
'
ppFileName = "notes.ppt"
ppFilePath = docPath & "\" & ppFileName
'
Set ppApp = CreateObject("PowerPoint.Application")
'
ppApp.Visible = True
ppApp.Activate
'
Set ppPres = ppApp.Presentations.Open(ppFilePath)
Set oSlides = ppPres.Slides
'
For Each oSlide In oSlides
'
oTable.Rows.Add
Set oRow = oTable.Rows(oTable.Rows.Count)
oSlide.NotesPage.Shapes(2).TextFrame.TextRange.Copy
oRow.Cells(1).Range.Text = "slide " & oSlide.SlideIndex
oRow.Cells(2).Range.PasteSpecial ppPasteRTF
'
Next oSlide
'
End Sub
'-------------------------------------------------------------

Advertisements

January 5, 2011 - Posted by | PowerPoint, VBA, Word

5 Comments »

  1. I am not a pro at the macro, but I am having a problem working this puppy. When I run the macro in the debug window, I get “Compile Error: User-defined type not defined with “Dim ppApp As PowerPoint.Application” highlighted.

    Using Office 2011 on a Mac. Is the Mac the problem?

    Comment by Joel Barker | December 2, 2011 | Reply

    • Hi Joel,

      There is no error within your defined type.
      Is this type defined with-in PowerPoint or with-in Excel/Word?

      If the type is defined in Excel or Word, then you will need to include the PowerPoint Object Library. In the Visual Basic Editor, go to Tools and select References. From the dialog box select Microsoft PowerPoint #.# Object Library

      Hope this will resolve the error.

      Regards,
      Sid

      Comment by Sid | December 4, 2011 | Reply

  2. I am facing another problem.

    It is giving “The request member of the collection does not exist” on line

    Set oTable = oDoc.Tables(1)

    What should I do to handle this error???

    Comment by Vivek Mittal | December 6, 2011 | Reply

    • Hi Vivek,

      You will need to add a table containing two columns in Word.

      Regards,
      Sid

      Comment by Sid | December 6, 2011 | Reply

      • I have already tried that, it is prompting that

        “The specified value is out of Range”

        on the line

        oSlide.NotesPage.Shapes(1).TextFrame.TextRange.Copy

        Is there a way to copy (simple copy, without table) the notes content of a PPT on separate pages of the document?

        (Slide 1 Notes should come on Page 1 of the Document,
        Slide 2 Notes should come on the Page 2………………..)

        It will be very helpful for my work.

        Comment by Vivek Mittal | December 7, 2011


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: