Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default X button at top right of userforms

Hey

A workbook opens when a userform is loaded. I have it
setup for that same workbook to close when the
commandbutton named "Close" is clicked, but I also would
like to get it to where it closes when the X at the top
right of the userform is clicked as well. I dont know
what event this would be. How would I get it to do this?


Thank you
Todd Huttenstine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default X button at top right of userforms

Todd,

The UserForm_QueryClose event will fire when the user closes the
form with the X button in the top right of the form.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Todd Huttenstine" wrote in
message ...
Hey

A workbook opens when a userform is loaded. I have it
setup for that same workbook to close when the
commandbutton named "Close" is clicked, but I also would
like to get it to where it closes when the X at the top
right of the userform is clicked as well. I dont know
what event this would be. How would I get it to do this?


Thank you
Todd Huttenstine



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default X button at top right of userforms

Todd,

That is Query

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
'do your stuf
End If
End Sub

You could even trap the un load from within code (such as your button) by
checking vbFormCode as well.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine" wrote in message
...
Hey

A workbook opens when a userform is loaded. I have it
setup for that same workbook to close when the
commandbutton named "Close" is clicked, but I also would
like to get it to where it closes when the X at the top
right of the userform is clicked as well. I dont know
what event this would be. How would I get it to do this?


Thank you
Todd Huttenstine



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
UserForms soniya Excel Programming 1 April 11th 04 11:14 AM
Radio Button Selection in UserForms Big Chris[_32_] Excel Programming 3 February 5th 04 12:26 PM
"minimize" button for userforms Valeria[_2_] Excel Programming 1 January 20th 04 10:16 AM
Form Button with 3 Userforms Help [email protected] Excel Programming 3 November 21st 03 06:00 PM
userforms again... Jo[_4_] Excel Programming 3 September 21st 03 12:31 AM


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