A bug in my macro
Posted by Sarah on July 31, 2001 2:59 PM
I have a macro that saves and closes a workbook if nothing has been entered or no macro has been called for 5 minutes. But when the workbook closes (either by macro or by clicking the X) it reopens and closes a variable number of times before finally staying closed. If Excel is closed while the workbook is open this doesn't happen. I've posted the code below and if anyone has any insight into what's causing this, it would be greatly appreciated.
Dim lasttime As Double
Dim thistime As Double
Application.OnEntry = "zerotime"
lasttime = Now
thistime = Now
Application.StatusBar = False
Application.OnEntry = ""
thistime = Now - lasttime
Application.StatusBar = "Unused for " + Format(thistime, "hh.mm.ss") + ". Closes at 00.05.00"
If thistime > TimeSerial(0, 5, 0) Then
Application.OnTime Now() + TimeSerial(0,0,1), "countertime"
lasttime = Now()