View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_4_] Jim Thomlinson[_4_] is offline
external usenet poster
 
Posts: 1,119
Default Prevent a workbook being closed with the X

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)
--
HTH...

Jim Thomlinson


"Mark" wrote:

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
--
Mark