简体   繁体   English

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

[英]How to Differentiate SaveAs call and Save call in PowerPoint events?

I'm writting AddIn for PowerPoint 2010. I'm using two functions of PowerPoint.我正在为 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)

When I perform Save operation (Ctrl+S) or SaveAs (File -> SaveAs) on powerpoint it executes Application_PresentationBeforeSave() method.当我在 powerpoint 上执行保存操作 (Ctrl+S) 或 SaveAs (File -> SaveAs) 时,它会执行Application_PresentationBeforeSave()方法。

But I need to differentiate these two calls (Ctril+S & SaveAs) and accordingly perform some task.但是我需要区分这两个调用(Ctrl+S 和 SaveAs)并相应地执行一些任务。 So how can I differentiate these two calls in BeforeSave method ??那么如何在 BeforeSave 方法中区分这两个调用?

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.对于 Word,在Application_DocumentBeforeSave(ByVal Doc As Microsoft.Office.Interop.Word.Document, ByRef SaveAsUI As Boolean, ByRef Cancel As Boolean)有 SaveAsUI 标志,用于区分此方法是否已被 SaveAs 或 Ctrl+S 操作调用。

So is there any flag/property which differtiate same things in PowerPoint ??那么是否有任何标志/属性可以区分 PowerPoint 中的相同内容?

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.您需要重新调整功能区按钮的用途或将后台 UI 控件替换为您自己的控件,以便了解用户在 UI 中选择的操作。 In case of ribbon controls see the Temporarily Repurpose Commands on the Office Fluent Ribbon article in MSDN.如果是功能区控件,请参阅 MSDN 中Office Fluent Ribbon文章中的临时重新调整命令用途 The Backstage UI is described in the following articles in MSDN in depth: MSDN 中的以下文章深入介绍了 Backstage UI:

Introduction to the Office 2010 Backstage View for Developers 面向开发人员的 Office 2010 后台视图简介

Customizing the Office 2010 Backstage View for Developers 为开发人员自定义 Office 2010 Backstage 视图

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.如果使用 Ctrl+S 快捷键,您需要使用 Windows API 函数设置键盘挂钩,请参阅使用快捷键调用 Office 加载项中的函数以了解更多信息。

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我在 Ribbon.xml 中添加了函数调用

In MySaveAs() function I set one glbal variable.在 MySaveAs() 函数中,我设置了一个 glbal 变量。 And used it in BeforeSave mthod.并在 BeforeSave 方法中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM