Prevent a workbook being closed with the X

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

Guest

I am using Excel 97. Is there anyway that you can prevent users on a
workbook from closing the workbook with the 'X' in the top right hand corner?

Thanks
 
In the "thisworkbook" module add a BeforeClose event something like this

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
MsgBox "This is not how you close this workbook..."
End Sub

Then in the close button or however you intend to close the workbook add in an
Application.enableevents = false to keep this code from firing when you
really want to clost the book. (Just as a note I usually try to avoid doing
things like this because the users find it fraustrating when they can't close
a program through normal windows functions. They start doing things like
hitting the power button or going into the task manager and ending things)
 

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