Quantcast
Channel: General Office Development forum
Viewing all articles
Browse latest Browse all 2257

Events not fired in PowerPoint as expected when a new presentation is opened first...

$
0
0

Problem Description:
Microsoft Tool: Microsoft PowerPoint 2013 (Part of Microsoft Office Professional Plus 2013),  Ver - 15.0.4693.1002) - 32-Bit
In PowerPoint, we have Application Object Events which are triggered by the PowerPoint application at various stages. As per the documentations available, when an existing presentation is opened and new presentation is created, the following events are triggered.
In the case of opening an EXISTING presentation:
App_WindowDeactivate
App_WindowActivate
App_SlideSelectionChanged
App_WindowSelectionChange
App_PresentationOpen
App_AfterPresentationOpen

In the case of opening a NEW presentation:
App_WindowDeactivate
App_WindowActivate
App_NewPresentation
App_AfterNewPresentation
App_PresentationNewSlide
App_SlideSelectionChanged
App_WindowSelectionChange are to be triggered. 

While creating an add-in, I am encountering a strange situation. In the add-in I am trapping some of the above said events to implement the required functionality. Towards this, the add-in source has implemented RibbonOnLoad functionality for initializing the application. While the event is triggered and the functionality works fine in most cases, in the below mentioned case, the events triggering gets halted inbetween for some unknown reason! The steps to simulate are as follows.

- Create a PowerPoint macro enabled file and trap some of the above events. You may have debug statements to track the event firing.
- Create an add-in out of it and install it on to the PowerPoint application
- Close the PowerPoint application


Case A:
Step-1:
- Open an EXISTING presentation through PowerPoint (either through explorer or opening PowerPoint and then opening existing presentation)
- The following events are fired
RibbonOnLoad
App_WindowActivate
App_SlideSelectionChanged
App_WindowSelectionChange

Step-2:
Now, open a NEW presentation using BLANK presentation template. You see that the following events are fired.
App_WindowDeactivate
App_WindowActivate
App_SlideSelectionChanged
App_WindowSelectionChange
App_PresentationOpen
App_AfterPresentationOpen

Case B:

Step-1:

- Open a new presentation using BLANK presentation template. You see that the following events are fired.
RibbonOnLoad
App_NewPresentation

(Notice that none of the other events that got fired in the case of CASE A (Step-2), got fired in this case!)

Step-2:

Now, open an EXISTING presentation
- No events!!!
- None of the events that got fired in Case A (Step-1) are fired !

After this, even if we open an existing presentation or create new, the events are not triggered!

So, primarily, if the FIRST presentation that is opened is a NEW presentation (usingBLANK slide template), then, only partial events are fired and then none of the other events seem to fire when other presentations are opened. Only when they are getting closed, the closing events seem to fire!
However, if we open a new presentation using a template other than Blank, then the events fire normally!

Is this a bug and is there a work-around or am I missing something?

Have included the code sample to check out the same.

Under Main module:

Option Explicit

Public oEH As New clsAppEvents

Sub InitApp()
  Set oEH.App = Application
End Sub

Public Sub OnLoadRibbon(myRibbon As IRibbonUI)
    Debug.Print ("Ribbon Loaded")

    InitApp
End Sub

Under Class Modules

Option Explicit

Public WithEvents App As Application

Private Sub App_AfterDragDropOnSlide(ByVal Sld As Slide, ByVal X As Single, ByVal Y As Single)
Debug.Print "App_AfterDragDropOnSlide"
End Sub

Private Sub App_AfterNewPresentation(ByVal Pres As Presentation)
Debug.Print "App_AfterNewPresentation"
End Sub

Private Sub App_AfterPresentationOpen(ByVal Pres As Presentation)
Debug.Print "App_AfterPresentationOpen"
End Sub

Private Sub App_AfterShapeSizeChange(ByVal shp As Shape)
Debug.Print "App_AfterShapeSizeChange"
End Sub

Private Sub App_ColorSchemeChanged(ByVal SldRange As SlideRange)
Debug.Print "App_ColorSchemeChanged"
End Sub

Private Sub App_NewPresentation(ByVal Pres As Presentation)
Debug.Print "App_NewPresentation"
End Sub

Private Sub App_PresentationBeforeClose(ByVal Pres As Presentation, Cancel As Boolean)
Debug.Print "App_PresentationBeforeClose"
End Sub

Private Sub App_PresentationBeforeSave(ByVal Pres As Presentation, Cancel As Boolean)
Debug.Print "App_PresentationBeforeSave"
End Sub

Private Sub App_PresentationClose(ByVal Pres As Presentation)
Debug.Print "App_PresentationClose"
End Sub

Private Sub App_PresentationCloseFinal(ByVal Pres As Presentation)
Debug.Print "App_PresentationCloseFinal"
End Sub

Private Sub App_PresentationNewSlide(ByVal Sld As Slide)
Debug.Print "App_PresentationNewSlide"
End Sub

Private Sub App_PresentationOpen(ByVal Pres As Presentation)
Debug.Print "App_PresentationOpen"
End Sub

Private Sub App_PresentationPrint(ByVal Pres As Presentation)
Debug.Print "App_PresentationPrint"
End Sub

Private Sub App_PresentationSave(ByVal Pres As Presentation)
Debug.Print "App_PresentationSave"
End Sub

Private Sub App_PresentationSync(ByVal Pres As Presentation, ByVal SyncEventType As Office.MsoSyncEventType)
Debug.Print "App_PresentationSync"
End Sub

Private Sub App_ProtectedViewWindowActivate(ByVal ProtViewWindow As ProtectedViewWindow)
Debug.Print "App_ProtectedViewWindowActivate"
End Sub

Private Sub App_ProtectedViewWindowBeforeClose(ByVal ProtViewWindow As ProtectedViewWindow, ByVal ProtectedViewCloseReason As PpProtectedViewCloseReason, Cancel As Boolean)
Debug.Print "App_ProtectedViewWindowBeforeClose"
End Sub

Private Sub App_ProtectedViewWindowBeforeEdit(ByVal ProtViewWindow As ProtectedViewWindow, Cancel As Boolean)
Debug.Print "App_ProtectedViewWindowBeforeEdit"
End Sub

Private Sub App_ProtectedViewWindowDeactivate(ByVal ProtViewWindow As ProtectedViewWindow)
Debug.Print "App_ProtectedViewWindowDeactivate"
End Sub

Private Sub App_ProtectedViewWindowOpen(ByVal ProtViewWindow As ProtectedViewWindow)
Debug.Print "App_ProtectedViewWindowOpen"
End Sub

Private Sub App_SlideSelectionChanged(ByVal SldRange As SlideRange)
Debug.Print "App_SlideSelectionChanged"
End Sub

Private Sub App_SlideShowBegin(ByVal Wn As SlideShowWindow)
Debug.Print "App_SlideShowBegin"
End Sub

Private Sub App_SlideShowEnd(ByVal Pres As Presentation)
Debug.Print "App_SlideShowEnd"
End Sub

Private Sub App_SlideShowNextBuild(ByVal Wn As SlideShowWindow)
Debug.Print "App_SlideShowNextBuild"
End Sub

Private Sub App_SlideShowNextClick(ByVal Wn As SlideShowWindow, ByVal nEffect As Effect)
Debug.Print "App_SlideShowNextClick"
End Sub

Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
Debug.Print "App_SlideShowNextSlide"
End Sub

Private Sub App_SlideShowOnNext(ByVal Wn As SlideShowWindow)
Debug.Print "App_SlideShowOnNext"
End Sub

Private Sub App_SlideShowOnPrevious(ByVal Wn As SlideShowWindow)
Debug.Print "App_SlideShowOnPrevious"
End Sub

Private Sub App_WindowActivate(ByVal Pres As Presentation, ByVal Wn As DocumentWindow)
Debug.Print "App_WindowActivate"
End Sub

Private Sub App_WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As Boolean)
Debug.Print "App_WindowBeforeDoubleClick"
End Sub

Private Sub App_WindowBeforeRightClick(ByVal Sel As Selection, Cancel As Boolean)
Debug.Print "App_WindowBeforeRightClick"
End Sub

Private Sub App_WindowDeactivate(ByVal Pres As Presentation, ByVal Wn As DocumentWindow)
Debug.Print "App_WindowDeactivate"
End Sub

Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
Debug.Print "App_WindowSelectionChange"
End Sub

Appreciate your inputs.

-Satish


Viewing all articles
Browse latest Browse all 2257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>