Hi,
I have a Userform that hides the excel workbook from which it is generated.
This works fine and I use the following code:
Now, when I hit a commandbutton on my userform that says exit, I wanted excel to stop without asking to save, so I used this code:
This also works fine.
My problem is, that I have another button in my userform that opens a separate workbook and when I am done with this new workbook, I would like to be able to close it and continue with whatever I need in my userform. But when I close this new and separate workbook, the excel that runs my userform also closes.
How can I avoid this?
This also happens if I just open a new excel workbook normally and closes it. No matter what I ONLY want the userform to close if I press the exit button on the userform.
I have a Userform that hides the excel workbook from which it is generated.
This works fine and I use the following code:
Code:
Private Sub Workbook_Open()
Application.Visible = False
General.Show
End Sub
Now, when I hit a commandbutton on my userform that says exit, I wanted excel to stop without asking to save, so I used this code:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub
This also works fine.
My problem is, that I have another button in my userform that opens a separate workbook and when I am done with this new workbook, I would like to be able to close it and continue with whatever I need in my userform. But when I close this new and separate workbook, the excel that runs my userform also closes.
How can I avoid this?
This also happens if I just open a new excel workbook normally and closes it. No matter what I ONLY want the userform to close if I press the exit button on the userform.