I'm not sure how DoEvents works, but I believe that your macro would have to always be running, which means that no other macros or Events would ever execute as long as it was running.
Try this:
Sub StartTimer()
CheckTimer(1)
End Sub
Sub EndTimer()
CheckTimer(2)
End Sub
Sub ResetTimer()
CheckTimer(3)
End Sub
Sub CheckTimer(Optional ByVal iAction as Integer)
Static dtStart as Date
If iAction = 1 Then
dtStart = Time
ElseIf iAction = 2 then
dtStart = 0
ElseIf iAction = 3 Then
dtStart = Time
End If
If dtStart <> 0 Then
If Time - dtStart >= TimeSerial(0,5,0) Then
ThisWorkbook.Close True
Else
'check every 10 seconds
' allows other macros to run
Application.Ontime Now + TimeSerial(0,0,10), "'" & ThisWorkBook.Name & "'!CheckTimer"
End If
End If
End Sub
Bookmarks