f2e4
08-25-2009, 09:02 AM
Hey guys,
I have a spreadsheet with a simple userform - Userform1.
On this userform there is 2 command buttons - one for closing excel immediately and one for saving the workbook and the closing excel. Code is as follows:
Private Sub CommandButton1_Click()
'CLOSE WORKBOOK WITHOUT SAVING
Unload Me
UserForm1.Hide
Application.Quit
End Sub
Private Sub CommandButton7_Click()
'CLOSE WORKBOOK AND SAVE
Unload Me
UserForm1.Hide
ThisWorkbook.Save
Application.Quit
End Sub
However, everytime I run the code, excel does close down but I keep getting the error:
'Excel has encountered a problem and needs to close'
Is there a more savvy way of writing the above processes to prevent excel from producing this error.
As always, your help is greatly appreciated.
I have a spreadsheet with a simple userform - Userform1.
On this userform there is 2 command buttons - one for closing excel immediately and one for saving the workbook and the closing excel. Code is as follows:
Private Sub CommandButton1_Click()
'CLOSE WORKBOOK WITHOUT SAVING
Unload Me
UserForm1.Hide
Application.Quit
End Sub
Private Sub CommandButton7_Click()
'CLOSE WORKBOOK AND SAVE
Unload Me
UserForm1.Hide
ThisWorkbook.Save
Application.Quit
End Sub
However, everytime I run the code, excel does close down but I keep getting the error:
'Excel has encountered a problem and needs to close'
Is there a more savvy way of writing the above processes to prevent excel from producing this error.
As always, your help is greatly appreciated.