Run vba/macro when I end slideshow

Posted on 2009-04-19
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
    LVL 59

    Accepted Solution

    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

    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
    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

    Thanks Chris.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    This article describes how to make a simple, pseudo-random number generator in Microsoft PowerPoint. The code checks the generated numbers against a list of numbers already generated to prevent duplication. We used this as a youth group activity but…
    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…
    This video teaches viewers how to fit pictures into slides, crop and remove backgrounds, and alter photos to look more professional.
    The viewer will learn how to edit the master slide. They will also learn how to combine multiple themes into one master slide to use them in their presentation.

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now