Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Exiting a workbook | Excel Programming | |||
how do i get a pop up message on saving or exiting a document? | Excel Worksheet Functions | |||
How do I turn off saving. when I'm exiting an excel worksheet | Excel Discussion (Misc queries) | |||
Exiting a workbook | Excel Programming | |||
Exiting a workbook | Excel Programming |