How to cancel a closing event for PowerPoint, like in Word & Excel in PIA?

When Microsoft Word is closed, the close event can be canceled. The same goes for Excel.

But the PowerPoint close event does not have a cancel flag.

Can I cancel the event in any other way?

+4
source share
2 answers

In the closed case, you can set the document to Saved = False , this will force PowerPoint to ask the user if he wants to save the file with a Yes-No-Cancel message.

Using SendKeys({ESC}) shortly before the end of the event, it will send an escape to the message box, and the close event will be canceled.

+7
source
Example

: [does not work in PP2003]

 using MSPowerPoint = Microsoft.Office.Interop.PowerPoint; using MSOffice = Microsoft.Office.Core; protected virtual void AppEvents_PresentationClose(object sender, object hostObj) { MSPowerPoint._Presentation p = (MSPowerPoint._Presentation)hostObj; p.Saved = MSOffice.MsoTriState.msoFalse; SendKeys.Send("{ESC}"); } 
+1
source

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


All Articles