Convert PowerPoint Slides to Word Document Using VBA Macro

Category: MS Powerpoint

If you have PowerPoint file with lots of slides, sometimes it is very difficult to read even if you print multiple slides on single page. Copy pasting from PowerPoint to MS Word is difficult or tedious depending on what tricks are you using. If you came across this article, you already know what I am talking about.

So in order to make it extremely easy and keep most of the formatting as it is, I have created following VBA macro. VBA Macro is a program which you need to run it directly within PowerPoint.

Here are the steps to to convert PowerPoint slides to Word document.

Close all Microsoft Word files that you have open. Keep only blank Microsoft Word file open. This is a very important step. I have tested the macro only with single file open and if you have any other file open, there is a chance that macro will paste content into existing file.

Open only one PowerPoint file which you want to convert.

Go to Developers Tab > Visual Basic in PowerPoint. If you don’t have Developers tab. Search online on how to show Developer tab.

It will open up another window.

Right click on “VBAProject” > Insert > Module.

Paste the following code into the newly opened window.

Public LastTitle As String

Sub CopyText()

    ' for ms word
    Dim wdApp As Word.Application, wdDoc As Word.Document
    Set wdApp = GetObject(, "Word.Application")
    If wdApp Is Nothing Then Set wdApp = New Word.Application
    Set wdDoc = wdApp.ActiveDocument
    
    Dim sld As Slide
    Dim shp As Shape
    Set sld = Application.ActiveWindow.View.Slide
    Dim isTitle As Boolean
    Dim showTitle As Boolean
    
    For Each sld In ActivePresentation.Slides
    
        isTitle = False
        showTitle = True
        For Each shp In sld.Shapes
            If shp.HasTextFrame Then
                If shp.TextFrame.HasText Then
                    If LastTitle = shp.TextFrame.TextRange.Text Then
                        showTitle = False
                    End If
                    shp.TextFrame.TextRange.Copy
                    If Not isTitle Then
                        If showTitle Then
                            wdApp.Selection.Style = wdDoc.Styles("Heading 1")
                            wdApp.Selection.PasteAndFormat wdPasteDefault
                            wdApp.Selection.Move
                            'wdApp.Selection.Paste
                            'wdApp.Selection.PasteSpecial DataType:=wdPasteText
                            LastTitle = shp.TextFrame.TextRange.Text
                            
                        End If
                        isTitle = True
                    Else
                        wdApp.Selection.TypeParagraph
                        wdApp.Selection.PasteAndFormat wdPasteDefault
                        wdApp.Selection.Move
                        
                    End If
                    
                End If
            Else
                shp.Copy
                wdApp.Selection.PasteAndFormat wdPasteDefault
                'wdApp.Selection.Paragraphs.Add
                wdApp.Selection.Move
                
                wdDoc.Content.InsertAfter (vbCrLf)
             End If
        Next shp
    
    Next sld
    
    
End Sub



Then click on the next line of “Sub CopyText” and click on green arrow button to run VBA macro. You may also use keyboard shortcut F5 to execute/run macro.

Within a minute or less, you will get all your content in MS Word.

Limitations

After each image, the text/title will be shown on the same line. You may need to move the text/title to the next line using Enter key.

Generally PowerPoint has bulleted points which keeps too much space in Word document. Select all content and go to Paragraph Settings (Home Tab > Paragraph section, small button on bottom right corner). Under “Indent and Spacing” tab > “Spacing” section, tick “Don’t add space between paragraphs of same style” and click “OK” button.

You may need to adjust image sizes

You may want to further reduce number of pages by reducing margin and adding columns.

Share

0 comments

Your email address will not be published. Required fields are marked *