如何区分 PowerPoint 事件中的 SaveAs 调用和 Save 调用?

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

我正在为 PowerPoint 2010 编写插件。我正在使用 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) 或另存为(文件 -> 另存为)时,它会执行 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 中是否有任何 flag/property 可以区分相同的东西??

您需要重新调整功能区按钮的用途或将后台 UI 控件替换为您自己的控件,以便您了解用户在 UI 中选择的操作。如果是功能区控件,请参阅 MSDN 中的 Temporarily Repurpose Commands on the Office Fluent Ribbon 文章。后台 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 了解更多信息。

感谢 Eugene 给我指路。 我的问题得到解决。我尝试了你的建议。

这是我的解决方案的描述。 我在 Ribbon.xml 中添加了函数调用

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