![]() |
Cancel an exit
How do I give an option to stop an exit from a userform when the 'X' is used
on them form? Thanks |
Cancel an exit
Personally IMHO disable the Button, so the ONLY way to Close the form is via
a CommandButton instead. SEE: http://www.vbforums.com/showthread.php?t=363931 Corey.... "ranswrt" wrote in message ... How do I give an option to stop an exit from a userform when the 'X' is used on them form? Thanks |
Cancel an exit
Thanks I'll give that a try.
"Corey" wrote: Personally IMHO disable the Button, so the ONLY way to Close the form is via a CommandButton instead. SEE: http://www.vbforums.com/showthread.php?t=363931 Corey.... "ranswrt" wrote in message ... How do I give an option to stop an exit from a userform when the 'X' is used on them form? Thanks |
Cancel an exit
If you include this in the userform's module it will achieve your goal:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Cancel = True End Sub -- Jim "ranswrt" wrote in message ... | How do I give an option to stop an exit from a userform when the 'X' is used | on them form? | Thanks |
Cancel an exit
As a user, I like to click on the X button to close any dialog.
If you have special code built into your "Cancel" button, why not just call that same code. Option Explicit Private Sub CommandButton1_Click() MsgBox "Ok was clicked" End Sub Private Sub CommandButton2_Click() MsgBox "Cancel was clicked" Unload Me End Sub Private Sub UserForm_Initialize() With Me.CommandButton1 .Caption = "Ok" .Default = True End With With Me.CommandButton2 .Caption = "Cancel" .Cancel = True End With End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Call CommandButton2_Click End If End Sub ranswrt wrote: How do I give an option to stop an exit from a userform when the 'X' is used on them form? Thanks -- Dave Peterson |
All times are GMT +1. The time now is 10:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com