what vba event triggered when powerpoint enters in presentation mode

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

APD TorontoSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Professor JMicrosoft Excel ExpertCommented:
something like this

Private Sub App_SlideShowBegin(ByVal Wn As SlideShowWindow)

msgbox "ok"

End Sub
Wayne Taylor (webtubbs)Commented:
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 ExpertCommented:
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
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

APD TorontoSoftware DeveloperAuthor 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 ExpertCommented:
download the file and then change the extention from .zip to .pptm  then you can open it with powerpoint.
APD TorontoSoftware DeveloperAuthor 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 ExpertCommented:
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 DeveloperAuthor 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?
Professor JMicrosoft Excel ExpertCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft PowerPoint

From novice to tech pro — start learning today.