Hi Nigel,
Thanks for the code.
First of all, where do I use the code? Is it in "ThisWorkbook" or the form
in Visual Basic?
Secondly, what would you suggest on handling the situation below?
I created a user form, and when the workbook containing the user form opens,
the workbook will be hidden. On the user form, I have a close command
button, and when the user clicks on it, it will close the user form as well
as the workbook. However, when the user clicks on the top-right corner of X
button, the form closes but the workbook does not close. How should I do
either just to have my command button active or to close the workbook when
the user clicks on the X button?
Thanks.