首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PowerPoint,演示关闭事件后

PowerPoint,演示关闭事件后
EN

Stack Overflow用户
提问于 2012-02-01 22:12:38
回答 2查看 3.5K关注 0票数 3

PowerPoint 2007仅公开一个演示文稿关闭事件(PresentationClose),该事件在演示文稿关闭之前引发。

在我正在处理的几段代码中,我需要跟踪打开的演示文稿,因此需要对其中一个关闭的演示文稿做出反应。

一般来说,PowerPoint提出的活动就足够了。以下情况除外。

如果演示文稿在关闭时尚未保存,PowerPoint将显示一个对话框,询问用户是否要保存其演示文稿。如果用户单击“是”或“否”,则一切正常,因为演示文稿最终将关闭。但他也可以选择取消关闭...

在这种情况下,close事件被引发,演示文稿仍然在那里,但我的应用程序不知道它。

有人能给我一些变通方法吗?也许是用户单击cancel后引发的事件?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-02-02 23:57:59

您可能需要在PowerPoint 2010中添加的PresentationBeforeClosePresentationCloseFinal

如果用户在出现提示时单击“Yes”保存,然后单击“Cancel”退出“save Presentation”窗口,也可能会出现同样的问题。这仍然会使表示在应用程序中保持活动状态。

我想出的PowerPoint 2007解决方法(inspiration from here):

代码语言:javascript
复制
void Application_PresentationClose(PowerPoint.Presentation presentation)
{
    if (presentation.Saved == MsoTriState.msoFalse)
    {
        MessageBoxResult savePrompt = MessageBox.Show(string.Format("Do you want to save the changes you made to {0}?", presentation.Application.ActiveWindow.Caption), Globals.ThisAddIn.Application.Name, MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Yes);
        if (savePrompt == MessageBoxResult.Yes)
            System.Windows.Forms.SendKeys.Send("Y"); // trigger default SaveAs prompt
        else if (savePrompt == MessageBoxResult.No)
            System.Windows.Forms.SendKeys.Send("N"); // discard presentation
        else
            System.Windows.Forms.SendKeys.Send("{ESC}"); // disables default SaveAs prompt
    }
}
票数 1
EN

Stack Overflow用户

发布于 2012-02-02 23:51:09

我认为,像这样的东西就可以做到:

代码语言:javascript
复制
Private Sub PPTEvent_PresentationClose(ByVal Pres As Presentation)

  Dim x as Long
  with Application.Presentations
  If .Count > 0 Then
    For x = 1 to .Count
      If .Item(x) = Pres Then
         ' the presentation that triggered the event
         ' is still open; user must've canceled
      Else

      End If
    Next
  End if
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9097230

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档