![]() |
Cancel terminate event??
I wonder how to cancel a terminate event
If I invoke a terminate event by pressing the X button on the top right corner, then I ask does user really want to terminate then how am I going to cancel the terminate event if user click no Helps from you all are much appreciate! |
Cancel terminate event??
"Pop" wrote in message
... I wonder how to cancel a terminate event? If I invoke a terminate event by pressing the X button on the top right corner, then I ask does user really want to terminate, then how am I going to cancel the terminate event if user click no? Hi Pop, You can't cancel the Terminate event of a UserForm. Once your code has reached that point it's too late. What you need to trap is the QueryClose event instead. This event fires when anything attempts to close the UserForm and gives you the option to cancel. Here's a basic example: Private Sub UserForm_QueryClose(Cancel As Integer, _ CloseMode As Integer) ' If our code is not closing the form, ask the ' user if this is really what they want to do. If CloseMode < vbFormCode Then If MsgBox("Do you want to close", vbYesNo) = vbNo Then Cancel = True End If End If End Sub -- Rob Bovey, MCSE, MCSD, Excel MVP Application Professionals http://www.appspro.com/ * Please post all replies to this newsgroup * * I delete all unsolicited e-mail responses * |
All times are GMT +1. The time now is 06:05 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com