Excel VBA Error. Cannot SaveAs an Embedded PowerPoint Presentation in Office 2016 (works fine in prior versions)

We embed pptx files in Excel, then use Excel VBA code (like below) to open, then SaveAs the pptx file to the user's drive, then programmatically modify the pptx content based on Excel calculations.

The Excel VBA code below works fine in PowerPoint 2010 and 2013, but no longer works in PowerPoint 2016

Note:  I have similar code for Word and it works fine in Word 2016 (and prior versions).

 

Sub OpenCopyOfEmbeddedPPTFile() 'works with Office 2010 and 2013, but not on Office 2016

    Dim oOleObj As OLEObject

    Dim PPTApp As Object

    Dim PPTPres As Object

    Dim sFileName As String

    Set oOleObj = ActiveSheet.Shapes("PPTObj").OLEFormat.Object 'name of the embedded pptx object

    Set PPTApp = CreateObject("Powerpoint.Application")

    PPTApp.Visible = True

    sFileName = "C:\Users\Me\Documents\testPPT.pptx"

    OleObj.Verb Verb:=xlVerbOpen 'it opens successfully

    Set PPTPres = oOleObj.Object

    PPTPres.SaveAs Filename:=sFileName 'fails here (in Office 2016)

    PPTPres.Close

    GetObject(, "PowerPoint.Application").Presentations.Open sFileName

    'code to modify the Presentation (copy of the embedded pptx) based on Excel calculations

End Sub

 

Error: 

Run-time error '-2147467259 (80004005)':

Presentation.SaveAs : An error occurred while PowerPoint was saving the file.

 

Also, the following PowerPoint VBA (not Excel VBA) works fine for normal documents (not embedded), but fails when I run it in an opened embedded pptm.  Works fine in 2013 and 2010 embedded pptm's.

ActivePresentation.SaveAs FileName:="C:\Users\Me\Documents\testPPT.pptm"

 

Error:

Run-time error '-2147467259 (80004005)':  Presentation (unknown member) : An error occurred while PowerPoint was saving the file.

 

Windows OS version does not seem to matter.  Does not work on Office for Mac.

This error/bug occurs on all Office 2016 PCs we've tested it on.

 

Any way to resolve or workaround this error/bug?  Or is there another way to do the same thing (modify a copy of the embedded pptx so the embedded pptx is not modified)?

Change 

PPTPres.SaveAs Filename:=sFileName 'fails here (in Office 2016)

to 

PPTPres.SaveAs sFileName 

I'm not sure why but it did work for me.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I am able to reproduce this issue with any PowerPoint file type (e.g. pptx, pptm, potx, etc.).  Mooseman316's suggestion did not alleviate the issue.  Copying the slides into a new presentation and then saving it also gives me the same error, even though it is a new presentation and I've closed the original one.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated January 16, 2024 Views 1,635 Applies to: