Public Variable problem
I'd try:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If NoSave = True Then
me.saved = true ' a white lie to excel
end if
End Sub
Since you lied to excel, it won't see any changes that need to be saved. So it
won't prompt the user. And the close will just continue just like normal.
ordnance1 wrote:
I have the line below in a module:
Public NoSave As Boolean
In my Auto_Open routine I have:
Sub Auto_Open()
'
Events.Enable_Events
If ActiveWorkbook.ReadOnly = True Then
NoSave = True
Protection.ProtectAllSheets
Else
NoSave = False
Protection.UnProtectAllSheets
End If
Module7.StartPoint
Module6.StartTimer
End Sub
Then I in ThisWorkbook ihave the following"
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If NoSave = True Then
ThisWorkbook.Close False
End If
If NoSave = False Then
End If
End Sub
My problem is that when you click on either the Red X to close Excel or the
smaller X to close the workbook you are still prompted to save the workbook.
So it is not seeing NoSave as true, even when it was set to True in te
Auto_Open routine.
--
Dave Peterson
|