PC Review


Reply
Thread Tools Rate Thread

Buttons for saving and exiting a workbook

 
 
zak
Guest
Posts: n/a
 
      14th Jan 2009
Hi

Is there any way I can either have a form button or a control box button on
my workbook, which is called Laptop Upgrades.xlsm, to:

1) save my workbook
2) and then a separate button to close and exit out of my workbook

Please let me know
 
Reply With Quote
 
 
 
 
zak
Guest
Posts: n/a
 
      14th Jan 2009
Hi

Thanks for getting back to me so soon. This code works great. Thank you
very much.



"Incidental" wrote:

> Hi Zak
>
> You can add buttons to the sheet using Control toolbox then add the
> code to that button, you could have two seperate buttons or you could
> have a single button that would save and then ask the user if they
> want to quit... the code for both are listed below.
>
> 'One button to save workbook
> Private Sub CommandButton1_Click()
>
> ActiveWorkbook.Save
>
> End Sub
>
> 'One button to exit active workbook (also remove the comment mark to
> have the excel app shut down also)
> Private Sub CommandButton2_Click()
>
> ActiveWorkbook.Close
> 'Application.Quit 'close excel
>
> End Sub
>
> 'One button that will save and then ask the user if they wish to quit
> or not
> Private Sub CommandButton1_Click()
>
> ActiveWorkbook.Save
> resp = MsgBox("Do you wish to Exit?", vbInformation + vbYesNo,
> "Save complete")
>
> If resp = vbYes Then
> ActiveWorkbook.Close
> 'Application.Quit 'close excel
> Else
> Exit Sub
> End If
>
> End Sub
>
> I hope this helps you out.
>
> Steve
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel prompts for VBApassword after saving workbook under new name and exiting excel John Peach Microsoft Excel Programming 0 14th Oct 2010 12:44 PM
Message Box on exiting workbook cufc1210 Microsoft Excel Misc 1 30th Sep 2009 02:39 PM
Exiting a workbook Risky Dave Microsoft Excel Programming 3 12th Sep 2008 08:00 PM
Re: Exiting a workbook Dick Kusleika Microsoft Excel Programming 0 15th Aug 2003 05:30 PM
Re: Exiting a workbook John Wilson Microsoft Excel Programming 0 15th Aug 2003 04:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:50 PM.