disable the close "X" icon

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
Tools>Protection>Workbooks
Check the Window CheckBox
Stefi


„Andy†ezt írta:
 
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").RefersToRange = 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.
 
OK! Thanks again!

Patrick Molloy said:
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").RefersToRange = 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top