I have created some Office add-ins where I track whether or not a document/presentation is closed and then perform some custom code before closing the document/presentation.
All this code works without any problems in the Word add-in, but in the PowerPoint add-in I get an
"System.Runtime.InteropServices.COMException (0x80048240): Presentation (unknown member) : Invalid request. This operation cannot be performed in this event handler."-error when closing the PowerPoint application down. The method that is being called is presentation.Close().
The method works fine if it is called as part of a Ribbon eventhandler, but if it is called by any of the Application-evens (PresentationClose
, PresentationBeforeClose
or PresentationCloseFinal
) it fails to do the presentation.Close()
.
As mentioned I have identical code in a Word add-in which does not have this problem. I know that the eventhandling in the two products are different but I still can't figure out why it is a problem when the application is being shut down - or the presentation is closed - in PowerPoint.
Hope somebody can come with some good input.