newprogamer
Programmer
Hello Everyone,
I am having two problems (that I am aware of) when closing my program.
First, I have created an exit command button on a VB form. When the exit button is clicked, I need to close the VB form, Excel, and the Excel workbook. The code below leaves Excel open; however, it closes the workbook and the VB form. How do I properly close everything that is open when the exit button is clicked.
Second, if I click the X control button in the top right corner to close my VB form, when I try to reopen the program, I receive a message box to "Recover my work and restart Microsoft Excel". Do I need to add some type of code to ensure it is closing properly when the X control button is clicked?
Any help would be appreciated. Thanks is advance!
New programmer
I am having two problems (that I am aware of) when closing my program.
First, I have created an exit command button on a VB form. When the exit button is clicked, I need to close the VB form, Excel, and the Excel workbook. The code below leaves Excel open; however, it closes the workbook and the VB form. How do I properly close everything that is open when the exit button is clicked.
Code:
Private Sub cmdExitSpec_Click()
Workbooks.Close
Unload Me
End
End Sub
Second, if I click the X control button in the top right corner to close my VB form, when I try to reopen the program, I receive a message box to "Recover my work and restart Microsoft Excel". Do I need to add some type of code to ensure it is closing properly when the X control button is clicked?
Any help would be appreciated. Thanks is advance!
New programmer