what vba event triggered when powerpoint enters in presentation mode

APD Toronto
APD Toronto used Ask the Experts™
on
Hello Experts,

Among others, I've tried the following without luck

Sub SlideShowBegin(ByVal Wn As SlideShowWindow)

    MsgBox "Welcome Everyone!"

End Sub

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Professor JMicrosoft Excel Expert
Top Expert 2014

Commented:
something like this

Private Sub App_SlideShowBegin(ByVal Wn As SlideShowWindow)

msgbox "ok"

End Sub
It is called 'SlideShowBegin', but you need to use a class module in order to utilise events. See here for more info.
Professor JMicrosoft Excel Expert
Top Expert 2014

Commented:
here is the attached file.

i renamed pptm  to zip becuase it was not allowed to uploaded it in that format. download it and rename to .pptm and then when you open the file.  you can run the code on module then whenever you go on the slidemode it msgbox will automatically get triggered.
Presentation1.zip
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

APD TorontoSoftware Developer

Author

Commented:
Can any one walk me through?  I've done vba in Access many years, but here im completely lost.

I don't see a PowerPoint in the zip
Professor JMicrosoft Excel Expert
Top Expert 2014

Commented:
download the file and then change the extention from .zip to .pptm  then you can open it with powerpoint.
APD TorontoSoftware Developer

Author

Commented:
OK, i changed the name to .pptm, got to PowerPoint, and see the code under Alt+F11.  

Then, in the presentation I hit F5, see the slides but no message box?
Professor JMicrosoft Excel Expert
Top Expert 2014

Commented:
APD_Toronto

unlike other Office applications which they have event fired from within their object module.

powerpoint events are triggered differently.  in my previous attachment, you need to first run the code from the module and then when you click on slideshow it will run the code.  but if you want to avoid running the code first. then you would need to have an free powerpoint add-in developed by one  of the PowerPoint MVPs . you need to have that add-in enabled and then you can have the below code on a module and while the add-in is active, when you go to slidemode begin , the msgbox will be fired.

you can either download the event generator addin from MVP site http://officeone.mvps.org/eventgen/eventgen.html

or if you want the non-exe file i have uploaded both of them here one of them is the add-in and the other one is the sample code file.

Option Explicit


Sub OnSlideShowBegin(ByVal Wn As SlideShowWindow)
    MsgBox "OnSlideShowBegin: Beginning slide show: " + Wn.Presentation.Name
End Sub

Open in new window


the zip to be renamed back to .ppa
EventGenDemo.ppt
EventGenaddin.zip
APD TorontoSoftware Developer

Author

Commented:
The whole purpose behind me needing this, is because I simply need a startup boolean. For example, pptStarted = False, then when other events are executed, I set it to True.

I can't use a textbox for this, because when I change values in run-time, they remain in design-time - wierd...

What is the easiest way for me to set a start-up value, change it during presentation, then reset it for next time?
Microsoft Excel Expert
Top Expert 2014
Commented:
well, you will differently have to use the add-in in to make work the event handler in powerpoint.

now depending on which event you want to change the boolean to true and false. here are the list of events that are supported by that add-in

so one example would be that you set your pptStarted = False when the presentation opens you could use OnPresentationOpen() from the below code.  then depending on when you want to change it to true you could use any of the below events

OnPresentationClose() - Called before the presentation is closed.
OnPresentationNewSlide() - Called when a new slide is created in the presentation.
OnPresentationOpen() - Called after the presentation is opened.
OnPresentationPrint() - Called when the presentation is printed.
OnPresentationSave() - Called when the presentation is saved.

OnSlideShowBegin() - Called when the slide show begins.
OnSlideShowEnd() - Called when the slide show ends.
OnSlideShowNextBuild() - Called upon mouse-click or timing animation, but before the animated object becomes visible.
OnSlideShowNextSlide() - Called immediately before the transition to the next slide. For the first slide, it occurs immediately after the OnSlideShowBegin() event.

OnWindowActivate() - Called when the presentation window activates.
OnWindowBeforeRightClick() - Called when the user clicks the right mouse button. It is called before the right-click context menu is shown. This handler can disable showing of the context handler.
OnWindowDeactivate() - Called when the presentation window deactivates.
OnWindowSelectionChange() - Called when the currently selected shape or slide change

Sub OnPresentationClose(ByVal Pres As Presentation)
    MsgBox "OnPresentationClose: Presentation " + Pres.Name + " closed!"
End Sub

Sub OnPresentationNewSlide(ByVal Sld As Slide)
    MsgBox "OnPresentationNewSlide: New slide " + _
        Trim(Str(Sld.SlideID)) + "/" + Trim(Str(Sld.SlideIndex)) + " inserted"
End Sub

Sub OnPresentationOpen(ByVal Pres As Presentation)
    MsgBox "OnPresentationOpen: Presentation " + Pres.Name + " opened!"
End Sub

Sub OnPresentationPrint(ByVal Pres As Presentation)
    MsgBox "OnPresentationPrint: Presentation " + Pres.Name + " printed!"
End Sub

Sub OnPresentationSave(ByVal Pres As Presentation)
    MsgBox "OnPresentationSave: Presentation " + Pres.Name + " saved!"
End Sub

Sub OnSlideShowBegin(ByVal Wn As SlideShowWindow)
    MsgBox "OnSlideShowBegin: Beginning slide show: " + Wn.Presentation.Name
End Sub

Sub OnSlideShowEnd(ByVal Pres As Presentation)
    MsgBox "OnSlideShowEnd: Slide show ended: " + Pres.Name
End Sub

Sub OnSlideShowNextBuild(ByVal Wn As SlideShowWindow)
    MsgBox "OnSlideShowNextBuild: Showing next build: " + _
        Wn.Presentation.Name + ":" + Str(Wn.View.Slide.SlideID)
End Sub

Sub OnSlideShowNextSlide(ByVal Wn As SlideShowWindow)
    MsgBox "OnSlideShowNextSlide: Showing next slide: " + _
        Wn.Presentation.Name + ":" + Str(Wn.View.Slide.SlideID)
End Sub

Sub OnWindowActivate(ByVal Pres As Presentation, ByVal Wn As DocumentWindow)
    MsgBox "OnWindowActivate: " + Pres.Name
End Sub

Sub OnWindowBeforeRightClick(ByVal Sel As Selection, Cancel As Boolean)
    MsgBox "OnWindowBeforeRightClick: " + Sel.Parent
End Sub

Sub OnWindowDeactivate(ByVal Pres As Presentation, ByVal Wn As DocumentWindow)
    MsgBox "OnWindowDeactivate: " + Pres.Name
End Sub

Sub OnWindowSelectionChange(ByVal Sel As Selection)
    MsgBox "OnWindowSelectionChange: " + Sel.Parent
End Sub

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial