How to Differentiate SaveAs call and Save call in PowerPoint events?

佐手、 提交于 2019-12-11 12:11:12

问题


I'm writting AddIn for PowerPoint 2010. I'm using two functions of PowerPoint.

Application_PresentationBeforeSave(ByVal Pres As Microsoft.Office.Interop.PowerPoint.Presentation, ByRef Cancel As Boolean)

Application_PresentationSave(ByVal Pres As Microsoft.Office.Interop.PowerPoint.Presentation)

When I perform Save operation (Ctrl+S) or SaveAs (File -> SaveAs) on powerpoint it executes Application_PresentationBeforeSave() method.

But I need to differentiate these two calls (Ctril+S & SaveAs) and accordingly perform some task. So how can I differentiate these two calls in BeforeSave method ??

As for Word, in Application_DocumentBeforeSave(ByVal Doc As Microsoft.Office.Interop.Word.Document, ByRef SaveAsUI As Boolean, ByRef Cancel As Boolean) there is SaveAsUI flag which differentiate whether this method has been called by SaveAs or Ctrl+S action.

So is there any flag/property which differtiate same things in PowerPoint ??


回答1:


You need to repurpose the ribbon buttons or replace the backstage UI controls with your own so you will know what action users chose in the UI. In case of ribbon controls see the Temporarily Repurpose Commands on the Office Fluent Ribbon article in MSDN. The Backstage UI is described in the following articles in MSDN in depth:

Introduction to the Office 2010 Backstage View for Developers

Customizing the Office 2010 Backstage View for Developers

In case of Ctrl+S shortcuts you need set a keyboard hook using Windows API functions, see Using shortcut keys to call a function in an Office Add-in for more information.




回答2:


Thanks Eugene for showing me a way. My problem got resolve. I tried your suggestion.

Here is the description of my solution. I have added function call in Ribbon.xml

In MySaveAs() function I set one glbal variable. And used it in BeforeSave mthod.



来源:https://stackoverflow.com/questions/31336473/how-to-differentiate-saveas-call-and-save-call-in-powerpoint-events

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