Discussion Locked

Exit a program using visual basic

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello,

I'm pretty lame when it comes to knowing VB, but I figured there ought to be a simple vb scrip for exiting a program and returning to the desktop. Can anyone help?

I'm using PowerPoint and I want the user to be able to click a controlbuton that says "Exit" and powerpoint quits just like doing "File/Exit" on the menu bar. I also need to get past the "do you want to save" message with a "no" answer.

Thanks,
Randy

7 replies

by donq

begin comment lines with a single quote (')

'CLOSE A FORM OR WINDOW AND RETURN TO THE APPLICATION.

DoCmd.Close

'CLOSE AN APPLICATION AND RETURN TO WINDOWS.

DoCmd.Quit

Have fun with your new skills

by peyison

Randy,

Enter this sub in a VB code module:

Public Sub ExitPP()
ActivePresentation.Saved = True
Application.Quit
End Sub

You can add a new button on a toolbar and link it to this macro:

* Right click on a toolbar

* Select Customize...

* From the Categories list, select Macros

* Select ExitPP (or whatever you named your sub) and drag it to the toolbar you want it to be on

* You can right click on the new button and select Change Button Image, and select a new image- or select Edit Button Image and draw your own

* From the same right-click menu, you can select if you want the text to show, etc.

Hope this helps.

by raned

Your answer was right-on, very simple, clear, and most importantly: It Worked!

Thanks

by roc180

If you have multiple presentattions open use this:

Private Sub CmdButton1_Click()
Call Exit_App()
End Sub

Sub Exit_App()
With Application
For Each w In .Presentations
w.Save
Next w

.Quit
End With
End Sub

Good Luck

Neal Martinelli

This discussion is closed to new replies.