How to cancel the close event for PowerPoint like in Word & Excel in PIA?

Deadly 提交于 2019-12-10 17:30:18

问题


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

But the PowerPoint close event doesn't have cancel flag.

Is it possible to cancel the event in any other way?


回答1:


In the close event 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 box.

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




回答2:


example: [doesn't 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}");
}


来源:https://stackoverflow.com/questions/2560585/how-to-cancel-the-close-event-for-powerpoint-like-in-word-excel-in-pia

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!