So, how do I prevent someone from closing a form in Excel. I can't find any Cancel event.
So, how do I prevent someone from closing a form in Excel. I can't find any Cancel event.
The QueryClose Event is the one you want. You can check how the request to close was made and Cancel the close if you see fit.
Enjoy,
Tony
---------------------------------------------------------------
Give a man a fish and he'll eat for a day.
Teach him how to fish and he'll sit in a boat and drink beer all day.
I'm (slowly) building my own site: www.WordArticles.com
To follow up on Tony's suggestion, try this code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = 0 Then Cancel = True End Sub
Thanks for that. I'd looked at that event's name and thought it was something to do with using MS Query and a form. Makes sense now.
This nicely sorts the problem.
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Cancel = True End Sub