Turnkey
New Member
- Joined
- Aug 29, 2003
- Messages
- 22
I have an workbook which can only be closed via a button on my menu screen. The button runs a 'quit' macro which saves and quits. I've turned off the 'close' on my userforms and have a put 'cancel=true' into my workbook before close event. It was suggested to me that in order to avoid the workbook before close event i needed to turn DoEvents to false in my 'quit' macro. I did that. All worked fine until I tried to protect the code from being viewed then all hell broke loose! I went into Project Properties applied the lock for viewing and password. Went to save and then Runtime 1004 document not saved appeared. It took me a while to go back into project properties and just remove the check mark in the lock for viewing. I left the passwords in the boxes because if I remove them the same 1004 keeps coming up. What am I doing wrong? My code is as follows:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Cancel = True
End Sub
Sub quitter()
Application.ScreenUpdating = False
resetwindow - just reset's window and menubars
UserForm1.Hide
ActiveWorkbook.Save
Application.EnableEvents = False
Application.Quit
End Sub
Private Sub CommandButton5_Click() - button code
quitter
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Cancel = True
End Sub
Sub quitter()
Application.ScreenUpdating = False
resetwindow - just reset's window and menubars
UserForm1.Hide
ActiveWorkbook.Save
Application.EnableEvents = False
Application.Quit
End Sub
Private Sub CommandButton5_Click() - button code
quitter
End Sub