Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Disable Close Button | Excel Discussion (Misc queries) | |||
Disable Close "X" button on User Forms | Excel Programming | |||
macro to close excel application other than application.quit | Excel Programming | |||
Disable close button of Modeless Userform | Excel Programming | |||
SIMPLEST way to disable "close" button on form? | Excel Programming |