PC Review


Reply
Thread Tools Rate Thread

Close Button Removal

 
 
kirkm
Guest
Posts: n/a
 
      23rd Feb 2007


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

Thanks - Kirk
 
Reply With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      23rd Feb 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> Is it possible to remove or inhibit a Forms Close button (Top RH 'X')
>
> Thanks - Kirk



 
Reply With Quote
 
kirkm
Guest
Posts: n/a
 
      23rd Feb 2007
On Thu, 22 Feb 2007 21:47:10 -0500, "Tom Ogilvy" <(E-Mail Removed)>
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make prevent the Validate event from going off when the user hits the Close button (the X button) or selects "Close" from the system menu? 0to60 Microsoft Dot NET Framework Forms 5 10th Sep 2008 10:46 AM
Disable Close button and remove Close menu and then reactivate fpsoft Microsoft Dot NET Framework Forms 0 23rd Sep 2007 03:55 PM
Excel shoud not close all active books when clicking close button =?Utf-8?B?dGVjaG5vbWlrZQ==?= Microsoft Excel Misc 0 10th Jun 2005 05:35 PM
excel - Windows close button (x) should only close active workboo. =?Utf-8?B?Q29mZmVlQWRpY3Q=?= Microsoft Excel Setup 3 8th Feb 2005 04:30 AM
Excel 2000 Workbook close button hides instead of close Steven Robinson Microsoft Excel Misc 3 13th Aug 2003 11:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:36 PM.