Is it possible to autosave and close an Excel workbook after a period of inactivity?
Thanks
Is it possible to autosave and close an Excel workbook after a period of inactivity?
Thanks
Welcome to the forum E199,
I haven't used this for quite a while, but it has worked for me in the past.
In a regular module put:
Dim TheTime As Long
Sub StartTimer()
TheTime = Timer
Application.OnTime Now + TimeValue("00:10:00"), "CloseSave"
End Sub
Sub CloseSave()
If Timer - TheTime > 580 Then
ThisWorkbook.Close SaveChanges:=True
End If
End Sub
Then in the Workbook code put:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
StartTimer
End Sub
Hope this helps.
Private Sub Workbook_Open()
StartTimer
MsgBox "Remember that this workbook will close automatically after 10 minutes of inactivity"
End Sub