Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Preventing Form Dialog dismiss (Red X)

I want to detect if someone click the Red X to dismiss the form instead of my
OK or Cancel command buttons. Even better would be to prevent the form from
being dismissed in the first place.

I looked in the Object Browser for UserForm and did not find a BeforeUnload
event. I see the Terminate event, but it appears this is too late to prevent
the form from being terminated.

Is there something I'm missing?

inTHANKSadvance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Preventing Form Dialog dismiss (Red X)

Jim,

You can use the userform QueryClose event to prevent the form from closing.

Something like...

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode < 1 Then Cancel = True
MsgBox "Please use the cancel button to exit. "
End Sub

Regards,
Jim Cone
San Francisco, USA


"Jim Zeeb" wrote in message
...
I want to detect if someone click the Red X to dismiss the form instead of my
OK or Cancel command buttons. Even better would be to prevent the form from
being dismissed in the first place.

I looked in the Object Browser for UserForm and did not find a BeforeUnload
event. I see the Terminate event, but it appears this is too late to prevent
the form from being terminated.

Is there something I'm missing?

inTHANKSadvance
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Preventing Form Dialog dismiss (Red X)

This might be even more useful...

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode < 1 Then
Cancel = True
MsgBox "Please use the cancel button to exit. "
End If
End Sub


Jim Cone
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Preventing Form Dialog dismiss (Red X)

Thanks Jim,

That was just what I was looking for.
:)

"Jim Cone" wrote:

This might be even more useful...

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode < 1 Then
Cancel = True
MsgBox "Please use the cancel button to exit. "
End If
End Sub


Jim Cone

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
dismiss blanks in lookup Manuel Excel Worksheet Functions 5 July 30th 07 02:32 AM
Dialog & User Form bach New Users to Excel 2 August 13th 05 09:35 PM
How to resize Data Form dialog window? Compucat Excel Worksheet Functions 1 June 8th 05 11:24 PM
Dialog Box/Form Help! Rutgers_Excels[_6_] Excel Programming 0 October 8th 04 07:01 PM
Trapping and preventing a form from being e-mailed before validation quartz Excel Programming 1 April 27th 04 01:50 PM


All times are GMT +1. The time now is 05:40 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"