VBA & Macro Problems

Fix PowerPoint Close Errors for Embedded Presentations in Excel VBA

John WilsonJohn Wilson Nov 13, 2026 869 views

Question details

User needs an Excel VBA macro that opens an embedded PowerPoint presentation, edits it, and automatically closes it without raising error 80048240.

Fix PowerPoint Close Errors for Embedded Presentations in Excel VBA
Product
Microsoft Excel VBA with embedded PowerPoint
Device & OS
Windows 10 Enterprise
Scenario
Automating an embedded PowerPoint OLE object from Excel VBA to copy a chart and paste it into the presentation.
Observed behavior
Calling ppPres.Close during the event handler triggers error -2147188160 (80048240): Presentation.Close: Invalid request. This operation cannot be performed in this event handler.
Before you start

Open the workbook in Excel, press Alt+F11 to enter the VBA editor, and confirm that the target shape is an embedded OLE object with an OLEFormat.ProgID that contains 'PowerPoint.'.

Solution 1Recommended

Delay the Close Call with DoEvents and Application.OnTime

Use this solution when PowerPoint.Close fails only during automatic opening and closing inside the same Excel VBA event handler.

The error 80048240 is an OLE event-state limitation: PowerPoint rejects a Close call while the embedded object is still initializing or while the event handler is still running. Adding DoEvents and deferring cleanup with Application.OnTime gives the object time to become ready.

1
Open the VBA editor

In Excel, press Alt+F11 to open the Microsoft Visual Basic for Applications editor and select the module that contains the macro.

2
Add DoEvents after opening

After the line that opens the embedded object, such as pShape.OLEFormat.Verb xlOpen, insert DoEvents so Excel can process pending OLE operations before the next call.

3
Move close and quit to a delayed procedure

Put ppPres.Close and ppApp.Quit in a separate Sub, then schedule it from the event handler with Application.OnTime Now + TimeValue("00:00:02"), so the cleanup runs after the event handler returns.

4
Run the macro

Go to the Developer tab, click Macros, select the macro, and click Run. Verify that the embedded presentation opens, receives the update, and closes without error.

Delay the Close Call with DoEvents and Application.OnTime
Error 80048240 avoided: Deferring the close call until after the event handler resolves the invalid request error.
Free Microsoft Office alternative

Use WPS Office as a Free Alternative for Excel VBA and PowerPoint Automation

If PowerPoint Close error 80048240 is tied to Microsoft Office event-handler restrictions, WPS Office provides a free, lightweight suite that opens Excel workbooks and PowerPoint files with familiar VBA and formatting support, making it easier to handle daily automation without the same overhead.

Free to download and use for everyday spreadsheet and presentation tasksOpens and saves .xlsx, .xlsm, .pptx, and .ppt files with format compatibilityFamiliar ribbon interface and macro/VBA editing workflowLightweight design that reduces system resource usage during automation
microsoft office alternative - wps office

Frequently Asked Questions

Why does calling ppPres.Close in an Excel VBA event handler raise error 80048240?

PowerPoint rejects the Close request when the embedded object is still initializing or when the call runs inside the same event handler. Add DoEvents after opening the object and delay the cleanup with Application.OnTime so the event handler completes first.

Can I use late binding to avoid the PowerPoint object library reference?

Yes. Declare ppApp and ppPres as Object, use pShape.OLEFormat.Object.Object to obtain the presentation, and get the application with ppPres.Application. Late binding avoids requiring the Microsoft PowerPoint Object Library reference.

Why does the macro work when I open the embedded PowerPoint manually first?

Manual opening gives the PowerPoint OLE object enough time to fully initialize before VBA takes over. The automatic path must reproduce that delay with DoEvents and Application.OnTime.

How do I close both the embedded presentation and the PowerPoint application?

Call ppPres.Close first, then call ppApp.Quit. Do not call Quit on the presentation object because Quit belongs to the PowerPoint application object.

Does this error also occur in WPS Office?

The error is most commonly reported in Microsoft Office. WPS Office supports Excel and PowerPoint file formats and provides a lightweight alternative for similar editing and macro tasks, but VBA object behavior can differ.