Excel VBA can't save on Embedded PowerPoint Presentation in Office 2016

We insert the pptx files into Excel, and then use the Excel VBA code (for example, below), then SaveAs the pptx file to the user's disk, then programmatically change the contents of pptx based on Excel calculations.
The Excel VBA code below works fine to control PowerPoint 2010 and 2013, but no longer works for PowerPoint 2016.
Note: I have similar code for Word, and it works great for Word 2016 (and previous 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:
Runtime Error '-2147467259 (80004005)': Presentation.SaveAs: An error occurred while PowerPoint was saving the file.

, PowerPoint VBA ( Excel VBA) ( Excel), , pptm. 2013 2010 .

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

: '-2147467259 (80004005)': ( ): , PowerPoint .

Windows, , . Office Mac.

? ( pptx, pptx )? Office 2016?

+4
2

PowerPoint 2016 SaveAs SaveCopyAs .

- , . .

, BuiltInDocumentProperties .

Option Explicit

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 PPTNewPres As Object
    Dim sFileName As String
    Set oOleObj = ActiveSheet.Shapes("PPTObj").OLEFormat.Object 'name of the embedded pptx object

    oOleObj.Verb 3
    Set PPTPres = oOleObj.Object

    Set PPTApp = PPTPres.Application
    PPTApp.Visible = True

    'We can't save the embedded presentation in 2016, so let copy the clides to a new presentation
    Set PPTNewPres = PPTApp.Presentations.Add
    PPTPres.Slides.Range.Copy
    PPTNewPres.Slides.Paste

    'We may need to copy other things, like BuiltInDocumentProperties
    'TODO

    'Close the original
    PPTPres.Close

    sFileName = "C:\Users\Me\Documents\testPPT121.pptx"
    sFileName = "C:\users\andrew\desktop\testPPT12111-FOOJANE.pptx"
    PPTNewPres.SaveAs sFileName

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

    'Quit PPT
    'PPTNewPres.Close
    'PPTApp.Quit

End Sub
+2

, , PPTM PPTX

PPTPres.SaveAs Filename:=sFileName 

to

PPTPres.SaveAs sFileName

:

PPTPres.SaveCopyAs sFileName

PPTM

0

Source: https://habr.com/ru/post/1648552/


All Articles