View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Andy Andy is offline
external usenet poster
 
Posts: 414
Default disable the close "X" icon

OK! Thanks again!

"Patrick Molloy" wrote:

name a cell 'GoodToClose and set its value to FALSE

your exit button code should set this to TRUE

Add the following code to the code page of ThisWorkbook

Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not (ThisWorkbook.Names.Item("GoodToClose").RefersToRa nge = True)
End Sub

The Cancel variable will be true, thus preventing the workbook closing if
the value of the range 'GoodToClose' is not set to TRUE
Note: This will also prevent Excel itself from closing.



"Andy" wrote:

I want to disable the close "X" icon on a workbook and worksheet. I have a
EXIT button on the worksheet aleady. Thanks for your help in advance!