Consulting

Results 1 to 7 of 7

Thread: VBA .Quit PPT : How to .Quit Only One Presentation?

  1. #1
    VBAX Regular
    Joined
    Feb 2022
    Posts
    37
    Location

    VBA .Quit PPT : How to .Quit Only One Presentation?

    I'm looking for help on how to close the active presentation only.
    If I use .close, the gray window stays open (because the ppt application didn't close).
    If I use .quit, then all open PPT Applications exit out.
    How can I cleanly just save and quit the active presentation with a single click?

    This code Saves the PPTM if any changes have been made and then .Quits, but the problem is that it will also close all other open PowerPoints.

    Sub SaveAndQuit ()
    With Application.ActivePresentation
    
        If Not .Saved And .Path <> "" Then .Save
    
    End With
    
    Next
    PowerPoint.Application.Quit
    
    End Sub
    Thank You For Your Time!

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Maybe

    Sub save_close()
    With ActivePresentation
    If Not .Saved and Path <>"" Then .Save
    .Close
    End With
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Feb 2022
    Posts
    37
    Location
    Thanks for the reply!

    Yeah, I tried that before, and it does save and close, but it leaves an open gray (application) window open, which I have to subsequently 'X' out of. (Is it just me? idk)
    The .Quit method will successfully close it all out, but it also closes every other PPT. I want to save/quit only one Presentation.

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    If you quit the application all PowerPoint will close there's no way around that.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Regular
    Joined
    Feb 2022
    Posts
    37
    Location
    OK, I was afraid of that. Thanks for letting me know that. Then, I'm looking for a way to .Close the Presentation entirely ( and not leave the gray window at the end).
    If you use the .close method, does the Presentation exit out entirely for you?

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    See if this works for you

    It should either close if there is only one presentation or close the active one leaving others open

    Sub quit()
    ActivePresentation.SlideShowWindow.View.Exit
    ActivePresentation.Windows(1).Close
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  7. #7
    VBAX Regular
    Joined
    Feb 2022
    Posts
    37
    Location
    Bingo! That's the magic. Thank you, Sir!

Tags for this Thread

Posting Permissions

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