Hey all - I am using Application.Ontime to close workbook automatically if a cell value doesn't change for a set amount of time. I am having an issue with the Ontime procedure still running once file is closed. I have been looking around for similar issues, but all seem to just be related to code not using the exact same time/format to canacel the action. Pretty sure using the public variable as below is sufficient.
Code for file startup (in This Workbook code)
Initiate Application.Ontime. Time set for 2 min for testing (In Module 1)
If cell value changes, cancel the procedure, and start again (In This Workbook code)
Procedure to cancel the Ontime action (in Module 1)
Procedure that is called ( in Module 1)
I also call StopTheTime in the BeforeSave procedure in the worbook in case it is closed manually, but issue occurs when file is manually or automatically closed.
Some observations:
1.) If no change is made to the document, the code works as intended. If once change is made, the file closes after the set amount fo time, but as long as the application is open, it continues to reopen the document and run procedure and doesn't seem to stop. the one change should only initialize the Application.Ontime 1 additional time I would think, but as far as I can tell, there is no end (at least I didn't care to keep counting after ~20 interations).
2.) If I change "TimeToClose" variable while workbook is open (lets say from 2 minutes to 5 minutes), then change the document, then it resets the timer successfully for 5 minutes, but continues to reopen and close the document every 5 minutes. So this would make me think the cancel is successful.
I am probably overlooking something simple. Ideas?
Bookmarks