Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Close Button Removal



Is it possible to remove or inhibit a Forms Close button (Top RH 'X')

Thanks - Kirk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Close Button Removal

use the queryclose event.

http://support.microsoft.com/default...;en-us;Q166341
XL97: Preventing UserForm from Being Dismissed with Close Button (Q166341)



http://support.microsoft.com/default...;en-us;Q213713
XL2000: Preventing UserForm from Being Dismissed with Close Button (Q213713)





Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As _
Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
Msgbox "Can't close form this way. Use a button"
End if
End Sub

--
Regards,
Tom Ogilvy


"kirkm" wrote in message
...


Is it possible to remove or inhibit a Forms Close button (Top RH 'X')

Thanks - Kirk



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Close Button Removal

On Thu, 22 Feb 2007 21:47:10 -0500, "Tom Ogilvy"
wrote:

use the queryclose event.

http://support.microsoft.com/default...;en-us;Q166341
XL97: Preventing UserForm from Being Dismissed with Close Button (Q166341)



http://support.microsoft.com/default...;en-us;Q213713
XL2000: Preventing UserForm from Being Dismissed with Close Button (Q213713)





Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As _
Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
Msgbox "Can't close form this way. Use a button"
End if
End Sub


Thanks again Tom. A bit of pondering as I wanted both 'Save & Exit'
and 'Exit Without Saving'. Without the Forms Close button
circumventing either. Managed it thus:
--
Private Sub btnNoSave_Click()
mSave = 1
Unload Me
End Sub

Private Sub btnSave_Click()
mSave = 2
Unload Me
End Sub

Private Sub UserForm_Terminate()

If mSave < 1 Then
If mSave = 0 Then mSave = MsgBox("Save Changes", vbYesNo + 32, "This
Spreadsheet")

If mSave = 2 Or mSave = 6 Then

ActiveWorkbook.Save
End If
End If
End Sub
--

Maybe other ways but this seems to work. mSave was dimmed in the
declarations section and set to 0 in UserForm_Initialize.

Thanks - Kirk
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
Forms Command Button - Removal JMay Excel Discussion (Misc queries) 8 January 4th 07 06:33 PM
Don't let user close. Use macro button to close? mike Excel Programming 2 October 30th 06 01:31 PM
Excel Standard Toolbar button addition/removal problems? Valerie Dyet Excel Discussion (Misc queries) 1 July 13th 05 10:01 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


All times are GMT +1. The time now is 06:15 AM.

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"