Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cancel/Exit Sub | Excel Discussion (Misc queries) | |||
InputBox / VBA question ok = print, cancel = exit | Excel Worksheet Functions | |||
Userform SetFocus with Exit and Cancel | Excel Programming | |||
Cancel an application exit from VBA? | Excel Programming | |||
Cancel Exit on duplicate | Excel Programming |