[Last Call] Learn how to a build a cloud-first strategyRegister Now


Run vba/macro when I end slideshow

Posted on 2009-04-19
Medium Priority
Last Modified: 2012-05-06
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.

Question by:rav_rav
  • 2
  • 2
LVL 59

Accepted Solution

Chris Bottomley earned 1000 total points
ID: 24182106
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


Author Closing Comment

ID: 31572077
Hi Chris,

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

Thanks again.
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24193690
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


Author Comment

ID: 24194124
Thanks Chris.

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most folk recognise that Microsoft Excel, being a numbers-and-formulae-centric application attracts programmers due to the natural fit in mindset. Conversly, when opening Microsoft's dominant presentation creative application, few consider what…
 Regular Expressions Microsoft Word has sophisticated search tools that can search for patterns. For example if you wanted to search for all UK phone numbers that followed a pattern of five digits, a space and then six digits you can easily do th…
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question