如何在PowerPoint活动中区分SaveAs呼叫和保存呼叫?

时间:2015-07-10 08:55:05

标签: vb.net vsto powerpoint add-in powerpoint-vba

我正在为PowerPoint 2010编写AddIn。我正在使用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)

当我在powerpoint上执行保存操作(Ctrl + S)或SaveAs(文件 - > SaveAs)时,它会执行Application_PresentationBeforeSave()方法。

但我需要区分这两个调用(Ctril + S& SaveAs)并相应地执行一些任务。那么如何在BeforeSave方法中区分这两个调用?

对于Word,在Application_DocumentBeforeSave(ByVal Doc As Microsoft.Office.Interop.Word.Document, ByRef SaveAsUI As Boolean, ByRef Cancel As Boolean)中有SaveAsUI标志,用于区分SaveAs或Ctrl + S操作是否调用此方法。

那么有没有任何标志/属性在PowerPoint中具有相同的东西?

2 个答案:

答案 0 :(得分:3)

您需要重新调整功能区按钮的用途,或者使用自己的UI控件替换后台UI控件,以便了解用户在UI中选择的操作。如果是功能区控件,请参阅MSDN中的Temporarily Repurpose Commands on the Office Fluent Ribbon文章。 Backstage UI在MSDN的以下文章中进行了深入介绍:

Introduction to the Office 2010 Backstage View for Developers

Customizing the Office 2010 Backstage View for Developers

如果是Ctrl + S快捷键,则需要使用Windows API函数设置键盘挂钩,有关详细信息,请参阅Using shortcut keys to call a function in an Office Add-in

答案 1 :(得分:0)

感谢Eugene向我展示了一种方式。 我的问题得到了解决。我试过你的建议。

以下是我的解决方案的说明。 我在Ribbon.xml中添加了函数调用

在MySaveAs()函数中,我设置了一个glbal变量。并在BeforeSave方法中使用它。