Search code examples
vbapowerpoint

Export each slide of Powerpoint to a separate pdf file


I need to generate for each slide of my presentation a pdf file.

I'm using the following code:

ActivePresentation.ExportAsFixedFormat ActivePresentation.Path & "\" & ActivePresentation.Name & ".pdf", ppFixedFormatTypePDF, ppFixedFormatIntentPrint

This code works fine, but it exports all the slides into a unique pdf file.


Solution

  • You can do that: Below code will create pdf with adding the slide number at end of current folder, file name.

    Sub ExportSlidesToIndividualPDF()
    Dim oPPT As Presentation, oSlide As Slide
    Dim sPath As String, sExt As String
    
    Set oPPT = ActivePresentation
    sPath = oPPT.FullName & "_Slide_"
    sExt = ".pdf"
    
    For Each oSlide In oPPT.Slides
        i = oSlide.SlideNumber
        oSlide.Select
        oPPT.ExportAsFixedFormat _
            Path:=sPath & i & sExt, _
            FixedFormatType:=ppFixedFormatTypePDF, _
            RangeType:=ppPrintSelection
    Next
    Set oPPT = Nothing
    End Sub