Preventing user from closing Window


Posted by Tee on July 09, 2001 9:50 PM

Hi Everyone

I want to stop the user closing the Excel program from the X on the top right hand side of the Window.

I want them to use the command button that I have designed. The reason is that I have a macro that sets custom toolbars and if the user closes the program from the X, the toolbars donot return to the default ones.

Many thanks
Tee



Posted by Ivan F Moala on July 10, 2001 3:05 AM

Hi Tee
You can do this BUT, it is always good practice to
RESTORE the users original settings upon closing
down the workbook. This should be done via the
Workbooks Application event = Private Sub Workbook_BeforeClose(Cancel As Boolean)

So if your workbook has SET the commandbars up
upon openning then before closing it should reset
it back eg.

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.CommandBars("Formatting").Visible = True
Application.CommandBars("Custum").Visible = True

etc.
End Sub


Ivan