Sean15
Well-known Member
- Joined
- Jun 25, 2005
- Messages
- 719
- Office Version
- 2010
- Platform
- Windows
The code below closes file after three minutes of inactivity. But if there is an active cell, the code will not execute. For example, if I copy data from a cell, the cell remains active until I press Esc, at which time the code executes. Can someone update code so it deactivates active cell after 10 seconds, then allowing the three minutes shutdown countdown to execute? Thank you for your help.
VBA Code:
Dim CloseTime As Date
Sub TimeSetting()
CloseTime = Now + TimeValue("00:03:00")
On Error Resume Next
Application.OnTime EarliestTime:=CloseTime, _
Procedure:="SavedAndClose", Schedule:=True
End Sub
Sub TimeStop()
On Error Resume Next
Application.OnTime EarliestTime:=CloseTime, _
Procedure:="SavedAndClose", Schedule:=False
End Sub
Sub SavedAndClose()
ActiveWorkbook.Close Savechanges:=True
End Sub