Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Userform close

Hi,

I need to intercept when the user clicks the 'X' on the title bar to close
the userform instead of my 'Close' button and run code.

In researching on the newsgroup I found two sets of code. I am wondering
what the difference is between the two and which would be better to use.

Choice 1:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
MsgBox "This option will not close the form"
Cancel = 1
End If
End Sub

Choice 2:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode = vbFormControlMenu Then
' make user do what you want"
Cancel = True
End If
End Sub

--
Thanks for your help.
Karen53
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Userform close

"Nigel" wrote in message
...
They are essentially the same, vbFormControlMenu refers to the 'X' as the
mode of closing. CloseMode = 0 is the same. Cancel = 1; evaluates to
True.

I use, CloseMode = 0 and Cancel = True


Cancel is an Integer data type, so Cancel = 1 is the preferred coding.

Shhh, don't tell anyone, this is a secret, I've probably done it both ways.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Userform close

LOL, Thanks Howard
--
Thanks for your help.
Karen53


"Howard Kaikow" wrote:

"Nigel" wrote in message
...
They are essentially the same, vbFormControlMenu refers to the 'X' as the
mode of closing. CloseMode = 0 is the same. Cancel = 1; evaluates to
True.

I use, CloseMode = 0 and Cancel = True


Cancel is an Integer data type, so Cancel = 1 is the preferred coding.

Shhh, don't tell anyone, this is a secret, I've probably done it both ways.



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
Close Userform Bert[_2_] Excel Programming 1 October 21st 07 07:51 PM
Close Userform Bert[_2_] Excel Programming 1 October 21st 07 04:02 PM
Userform close button AOU Excel Discussion (Misc queries) 4 September 21st 07 05:56 PM
close UserForm [email protected] Excel Programming 3 November 9th 06 02:33 AM
Close a userform Alvin Hansen[_2_] Excel Programming 1 September 26th 04 12:56 PM


All times are GMT +1. The time now is 10:30 PM.

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

About Us

"It's about Microsoft Excel"