Hi

I have a spreadsheet with a timer built into it. I am using the "workbook_beforeclose" event to stop the timer if the user closes the workbook. In order to do this I need to ask the user if they want to savechanges and to stop Excel then asking the user the same question again as the workbook closes, I have disabled events. I then want to re-enable them AFTER the workbook has closed - I have the following code, but this leaves events disabled. If I re-enable events before the "Workbook.Close" line, Excel asks the user (twice!) if they want to save changes or not.

Any help would be appreciated!

Simon

Code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.EnableEvents = False
If Me.Saved = False Then
Message = MsgBox("Do you want to save changes?", vbYesNoCancel, "Save Changes?")
If Message = vbYes Then
StopTimer
Me.Close savechanges:=True
Application.EnableEvents = True
ElseIf Message = vbNo Then
StopTimer
Me.Close savechanges:=False
Application.EnableEvents = True
Else
Cancel = True
Application.EnableEvents = True
End If
Else
StopTimer
Application.EnableEvents = True
End If
End Sub