Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancel/Exit Sub Howard Excel Discussion (Misc queries) 3 December 16th 08 09:53 PM
InputBox / VBA question ok = print, cancel = exit todd78 Excel Worksheet Functions 4 August 9th 07 04:42 PM
Userform SetFocus with Exit and Cancel Neal Excel Programming 3 January 31st 06 01:21 AM
Cancel an application exit from VBA? helmekki[_98_] Excel Programming 3 October 28th 05 03:31 AM
Cancel Exit on duplicate Garry Jones Excel Programming 2 November 3rd 03 11:21 PM


All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"