![]() |
Timer to detect idle time?
If no changes are made to my workbook after
5 minutes, I want to autosave and close the workbook. Is something like this possible? thank you |
Timer to detect idle time?
Hi,
Yes that's possible with code. These get pasted into 'ThisWorkbook' Private Sub Workbook_Open() Call SetDelay End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Call Disable End Sub Private Sub Workbook_SheetCalculate(ByVal Sh As Object) Call Disable Call SetDelay End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _ ByVal Target As Excel.Range) Call Disable Call SetDelay End Sub Right click 'ThisWorkbook' insert module and paste this in Dim DownTime As Date Sub SetDelay() DownTime = Now + TimeValue("00:05:00") 'change time as needed Application.OnTime DownTime, "CloseBook" End Sub Sub CloseBook() ThisWorkbook.Save ThisWorkbook.Close End Sub Sub Disable() On Error Resume Next Application.OnTime EarliestTime:=DownTime, _ Procedu="CloseBook", Schedule:=False End Sub Save and close the workbook and on reopening 5 minutes of inactivilty will cause it to save and close. -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Robert Crandal" wrote: If no changes are made to my workbook after 5 minutes, I want to autosave and close the workbook. Is something like this possible? thank you . |
All times are GMT +1. The time now is 07:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com