Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Disable Close X Button On Excel Application

There is no simple way in Excel, and removing a windows function might not
be appreciated. What you could do is to change the BeforeClose workbook
event like so

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel=true
End Sub

which will stop Excel closing that workbook, thus won't shutdown. Problem
is, you can't close that workbook from code either. You could add a global
Boolean to test for it, and if you want to shutdown or close this workbook,
set it to True


Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not CloseOK Then
Cancel=true
End If
End Sub

although this does leave you open to Excel being closed if you shut this
workbook in code.

Removing the X takes API calls.

--

HTH

RP

"Celtic_Avenger" wrote in
message ...

Hi Peeps.

I have used the following code to disable the X button on Userforms,
but is this possible with the main Excel Application X button? If so
what do I need to change and where do I need to put the code?



Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode < vbFormCode Then
MsgBox "Please Note!" & Chr(13) & Chr(13) & "The Close Button Has Been
Disabled To Ensure No Loss Of Data." & Chr(13) & Chr(13) & "Please Use
The Save And Close Button At The Bottom Of This Menu!", _
vbOKOnly, "IMPORTANT!"
Cancel = True
End If
End Sub


Hope someone can help!

Celtic_Avenger



--
Celtic_Avenger
------------------------------------------------------------------------
Celtic_Avenger's Profile:

http://www.excelforum.com/member.php...o&userid=14101
View this thread: http://www.excelforum.com/showthread...hreadid=273978



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
Disable Close Button dan Excel Discussion (Misc queries) 5 September 22nd 06 07:39 PM
Disable Close "X" button on User Forms Celtic_Avenger[_49_] Excel Programming 2 October 11th 04 06:20 PM
macro to close excel application other than application.quit mary Excel Programming 1 September 14th 04 03:43 PM
Disable close button of Modeless Userform RB Smissaert Excel Programming 2 September 13th 03 09:46 PM
SIMPLEST way to disable "close" button on form? codytheretriever Excel Programming 4 August 7th 03 09:00 PM


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