Save ppt as pdf though excel RRS feed

  • Question

  • I’ve written a method in Excel that performs some calculations, updates charts, create an instance of PowerPoint, copy the charts to a new Powerpoint presentation and save the presentation as a .pptx. All that is working perfectly.


    I now need to save that same presentation as a pdf. To test, I wrote the following code in the Powerpoint IDE and it worked ok:


    ActivePresentation.ExportAsFixedFormat "c:\test.pdf", ppFixedFormatTypePDF


    However, I’m received a type mismatch error when I use the same ExportAsFixedFormat in excel. An extract of code in Excel is:


    Private ppApp As Object
    Private ppTemplate As Object
    Set ppApp = CreateObject("Powerpoint.Application")
    Set ppTemplate = ppApp.Presentations.Open(Filename:="C:\Report.pptx", withwindow:=False)
    ‘Other code       
    ppTemplate.ExportAsFixedFormat sPath & sMon & "\IT_Weekly_Update_" & sTimeStamp & ".pdf", ppFixedFormatTypePDF



    I know the type mismatch error is arising from ppFixedFormatTypePDF because it is part of the Powerpoint Object Model and not Excel’s. I added a reference to the Powerpoint Object Model and I am still received a type mismatch. I also declared ppFixedFormatTypePDF as type ppFixedFormatType and I still received the error.


    Any help with how to overcome this would be appreciate.




    • Edited by dfenton21 Thursday, July 12, 2012 7:46 PM
    Thursday, July 12, 2012 7:46 PM

All replies

  • See if using PpFixedFormatType.ppFixedFormatTypePDF makes a difference

    Thursday, July 12, 2012 8:58 PM
  • Hi,

    I'm trying to do something very similar! I have a spreadsheet with a ton of data. I would love to take some of the sheets I have and use them on individual slides as well as some charts. Then also, take the power point and convert that presentation to .pdf.

    Were you able to figure it all out? If so, would you mind sharing what you did?

    Monday, June 17, 2013 6:26 PM
  • I've had the same difficulties.

    It seems, that it's not possible to assign the FixedFormatType via Excel, if the constant used only exists in the PowerPoint VBlibrary.

    However, I solved it by writing a Sub in Excel, that creates a Module in the Powerpoint VBProject and writes a Sub in it, that uses the ExportAsFixedFormat-Function as one would use it in a PowerPoint VBProject.

    Executed by Powerpoint itself, that will work just fine.

    (Note: Even though I was able to create a Module via Excel in PowerPoint and fill it, I wasn't able to save the VBProject, so it will be lost, once you close the PPPresentation. Thats why I had to let my Excelsub create this Module every time I run the code.)

    Now you can call the routine in the PPVbProject from your ExcelVbProject via

    ApplicationObject(In this Case PowerPoint).Run("YourVBACreatedSub")

    If you want to transfer the Path from Excel to the PowerPointSub you can do that by primarily (in your Excel Code) saving your Path  in the Registry (SaveSetting) and retrieve it in the PowerPointSub (GetSetting)... Maybe that could be done with a global variable too, but I didn't try that.

    I know it's twisted, but it works :)

    I hope I could help you, since I haven't found anything else that would work. Because all other attempts with external PDF Printers and such failed horribly.



    Monday, May 12, 2014 1:54 PM