Powerpoint VBA App_SlideShowBegin
events, powerpoint, vba
Solution
Usually event handlers are installed as part of an add-in, where you'd initialize the class in the Auto_Open subroutine, which always runs when the add-in loads. If you want to include an event handler in a single presentation, one way to cause it to init is to include a shape that, when moused over or clicked fires a macro, which inits your event handler and goes to the next slide.
Problem
In order to use the SlideShowBegin event in Powerpoint, you have to have a Class Module configured the following way: ``` Public WithEvents App As Application Private Sub App_SlideShowBegin(ByVal Wn As SlideShowWindow) MsgBox "SlideShowBegin" End Sub ``` Then, inside of a non-class module, you have to create an object of that type and set the App to Application. ``` Dim X As New Class1 Sub InitializeApp() Set X.App = Application End Sub ``` Now, the only issue I have is, if you don't manually called InitializeApp with the Macro Menu in Powerpoint, the events don't work. You have to call this sub before anything can called at the beginning of a slideshow INCLUDING this sub. How can I go about calling this sub before running my powerpoint? Is there a better way to do this? EDIT: I've tried using Class_Initialize but it only gets called once it is first used or you make a statement like `Dim X as Class1; X = new Class1`