Consulting

Results 1 to 8 of 8

Thread: Close PowerPoint with slide show end

  1. #1
    VBAX Regular
    Joined
    Aug 2013
    Posts
    26
    Location

    Close PowerPoint with slide show end

    Hi,

    I would like to close PowerPoint, not only the presentation, after the slide show ends. I guess that should be possible with the event SlideShowEnd, right?
    For some reason the event doesn't seem to happen or affect any action.
    What's wrong?

    As a class:
    Public WithEvents App As Application
    
    As a module:
    Sub application_SlideShowEnd(ByVal Pres As Presentation)
    Dim App As Application
    Set App = CreateObject("PowerPoint.Application")
    With App.Presentations("makro5.pptm")
        .Saved = False
        .Quit 'or .Close?
    End With
    End Sub
    Btw: It's impossible to call the macro application_SlideShowEnd. Is it cause it's an event which doesn't have to be called?

    André

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    You cannot fire an event like that.
    Private Sub App_SlideShowEnd(ByVal Pres As Presentation)

    End Sub

    Needs to be in the class module and you also need to instantiate a new instance

    In a normal module
    Public instAPP As New Class1 'whatever the class is named

    Sub Instantiate()
    Set instAPP.App = Application
    End Sub

    Note this cannot be auto run except in an AddIn unless you use the onLoad event in the ribbon
    http://www.pptalchemy.co.uk/PowerPoi...Open_Code.html

    IF you are running other macros a much easier (though a little less reliable way) is to use this in a normal module

    Sub OnSlideShowTerminate(SW as SlideShowWindow)
    SW.Parent.saved=True
    App.Quit ' You shouldn't recreate the App I presume you have already done so
    End Sub

    This will only run reliably if other macros are accessed during the show,
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Aug 2013
    Posts
    26
    Location
    So far I'm running a macro by onload.

    Did I get it right that for this reason I won't need the class module?

    Do you mean IF I've "dim-ed" App in the class module? Either way (with App-dimming class module or without) it doesn't quit PowerPoint so far.

    Quote Originally Posted by John Wilson View Post
    You shouldn't recreate the App I presume you have already done so

    This will only run reliably if other macros are accessed during the show
    I run the macros of my two first threads before the show starts, but none while the show is running. Is this the issue? Or do I have to dim App in another macro? Or in the OnSlideShowTerminate macro?

    I suppose I'm quite off the track atm...

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    If you run ANY macro it should work OK.

    If you are doing all of this in PowerPoint there's no need to Dim App at all. By default the Application is taken to be the open application.

    Application.Quit

    If you really want to be sure

    PowerPoint.Application.Quit
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Regular
    Joined
    Aug 2013
    Posts
    26
    Location
    Works. Nice! Thank you

    Is there any way to open the marco editor (or the normal view) without disabling macros?

  6. #6
    VBAX Regular
    Joined
    Aug 2013
    Posts
    26
    Location
    I've changed the last line to ActivePresentation.Close. This way the users will be able to disable macros if they want to.

    What's good SW.Parent.Saved = True for? I tought it might be pretending the document has been saved to prevent the Save as dialog. But there is no change without that line. Does it actually save the file? The opposite would be nice. But if this line saves the file, I'd just have to leave out this line, cause as said, it doesn't seem to take any effect.

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    SW.Parent.Saved = True

    Just makes sure the Save dialogue doesan't pop up. Some macros convince ppt that changes have been made and therefore it needs to save before close.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    VBAX Regular
    Joined
    Aug 2013
    Posts
    26
    Location
    Yeh, just recognized it after turning off the close-line

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •