Run vba/macro when I end slideshow

Hello Experts,

How can I programmatically run a macro when I end a slideshow (i.e. when I right click during the slideshow and select "End Show")?

FYI: Specifically, what I am trying to do is call a macro I have which edits the hyperlinks within the slides.

Who is Participating?
Chris BottomleyConnect With a Mentor Software Quality Lead EngineerCommented:
In ordedr for it to work you must run a specific sub every time the PPT is opened I am afraid but assuming that then:

Add a class:

1. Insert class module, i.e. called myEvents:
Add contents:
Public WithEvents App As Application
2. Insert normal module, Add contents:

Option Explicit
public clsEvents As New myEvents

Sub InitializeApp()
    Set clsEvents.App = Application
End Sub
3. In the class module:
Select App and then the event you want to trigger your code.

Note InitializeApp needs to be run before the events will work, i.e. open event.

Private Sub App_SlideShowEnd(ByVal Pres As Presentation)
MsgBox "Closing Now"
End Sub

Open in new window

rav_ravAuthor Commented:
Hi Chris,

Thanks for your help.  Could you please explain what each snippet of the code you presented does?

Thanks again.
Chris BottomleySoftware Quality Lead EngineerCommented:
The text block is all about adding an event handler, unlike some MS apps PPT does not automatically add event handlers or even instantiate the code forf them.

The bit in the text field is tehrefore about adding the mechanism for events and once it is all in place adds the events to the PPT.

The snippet is the bit that actually uses the show ending event to trigger some activity

rav_ravAuthor Commented:
Thanks Chris.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.