PDA

View Full Version : [SOLVED:] VBA .Quit PPT : How to .Quit Only One Presentation?



Kellaroo
03-17-2022, 05:09 AM
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!

John Wilson
03-17-2022, 07:17 AM
Maybe


Sub save_close()
With ActivePresentation
If Not .Saved and Path <>"" Then .Save
.Close
End With
End Sub

Kellaroo
03-17-2022, 09:00 PM
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.

John Wilson
03-18-2022, 12:56 AM
If you quit the application all PowerPoint will close there's no way around that.

Kellaroo
03-18-2022, 01:23 AM
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?

John Wilson
03-18-2022, 03:12 AM
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

Kellaroo
03-18-2022, 05:40 AM
Bingo! That's the magic. Thank you, Sir!