none
Saving a PowerPoint Presentation as a pdf from With Outlook Code RRS feed

  • Question

  • I'm trying to write a macro in Outlook that will open a Powerpoint Presentation (that part works) then save it as a pdf.  The code I've seen does not seem to work when running the code from Outlook.  Here's what I've got so far, all the commented lines are my attempts that are based on msdn code.

    Sub PPD_PDF()

        Set powerpointapp = CreateObject("PowerPoint.application")
        powerpointapp.Presentations.Open "K:\PPD Minutes.pptx"

        'PowerPoint.ActivePresentation.ExportAsFixedFormat "C:\Users\rhammond\Documents\test.pdf", ppFixedFormatTypePDF, ppFixedFormatIntentScreen, msoCTrue, ppPrintHandoutHorizontalFirst, ppPrintOutputBuildSlides, msoFalse, , , , False, False, False, False, False

        'ActivePresentation.ExportAsFixedFormat _
        '    FileName:= "C:\Users\rhammond\Dropbox\PPD\" & ActivePresentation.Name & ".pdf", _
        '    FixedFormatType:=ppFixedFormatTypePDF, _
        '    ppFixedFormatIntentPrint,
            
        'PowerPoint.Application.ActivePresentation.SaveCopyAs( _
        '    "C:\Users\rhammond\Dropbox\PPD\PPD Minutes.pdf", _
        '    ppSaveAsPDF)
        
    End Sub

    Monday, January 26, 2015 10:17 PM

Answers

  • Here is the code that worked:

        With powerpointapp.ActivePresentation
            .SaveAs file, 32
        End With

    32 is the enumeration value for ppSaveAsPDF.  ppSaveAsPDF works if you run the code within PowerPoint, but appearently outside of PowerPoint you need to use the number.

    Tuesday, January 27, 2015 1:22 PM

All replies

  • Would you not want to replace the PowerPoint variable with powerpointapp?

    And prefix ActivePresentation with "powerpointapp."?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, January 26, 2015 10:46 PM
  • I think I tried that earlier, like this:

        powerpointapp.ActivePresentation.SaveCopyAs( _
            "C:\Users\rhammond\Dropbox\PPD\PPD Minutes.pdf", _
            ppSaveAsPDF)

    I get a "Compile Error, Expected:="

    Tuesday, January 27, 2015 12:44 PM
  • When I try this with the first code it compiles, but I get a Run-tiem error '13': Type mismatch.

    powerpointapp.ActivePresentation.ExportAsFixedFormat "C:\Users\rhammond\Documents\test.pdf", ppFixedFormatTypePDF, ppFixedFormatIntentScreen, msoCTrue, ppPrintHandoutHorizontalFirst, ppPrintOutputBuildSlides, msoFalse, , , , False, False, False, False, False

    Tuesday, January 27, 2015 12:53 PM
  • Here is the code that worked:

        With powerpointapp.ActivePresentation
            .SaveAs file, 32
        End With

    32 is the enumeration value for ppSaveAsPDF.  ppSaveAsPDF works if you run the code within PowerPoint, but appearently outside of PowerPoint you need to use the number.

    Tuesday, January 27, 2015 1:22 PM