Hello All,
I have code on how to make an excel file close automatically when idle for a specific time which is working fine.
I want to constantly show the countdown time until the timeout period of inactivity in the excel status bar. How do I do this? I tried below but obviously this will not work because it will update only when I touch the excel which I don't want to count inactivity
Thanks
Ajay N
CODE:
------
Module 1:
------------
Public NoActivity As Date
Public SuppressCalcEvent As Boolean
Public Sub ShutDown()
On Error Resume Next
Application.DisplayAlerts = False
SuppressCalcEvent = True
Call StopClock
With ThisWorkbook
.Save
.Close
End With
End Sub
Public Sub StartClock()
On Error Resume Next
NoActivity = Now + TimeValue("00:02:00")
Application.OnTime NoActivity, "ShutDown"
End Sub
Public Sub StopClock()
On Error Resume Next
Application.OnTime NoActivity, "ShutDown", , False
End Sub
Workbook Module:
--------------------
Private Sub Workbook_Open()
Call StartClock
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
End Sub
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
If SuppressCalcEvent Then Exit Sub
Call StopClock
Call StartClock
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Call StopClock
Call StartClock
End Sub
I have code on how to make an excel file close automatically when idle for a specific time which is working fine.
I want to constantly show the countdown time until the timeout period of inactivity in the excel status bar. How do I do this? I tried below but obviously this will not work because it will update only when I touch the excel which I don't want to count inactivity
Thanks
Ajay N
CODE:
------
Module 1:
------------
Public NoActivity As Date
Public SuppressCalcEvent As Boolean
Public Sub ShutDown()
On Error Resume Next
Application.DisplayAlerts = False
SuppressCalcEvent = True
Call StopClock
With ThisWorkbook
.Save
.Close
End With
End Sub
Public Sub StartClock()
On Error Resume Next
NoActivity = Now + TimeValue("00:02:00")
Application.OnTime NoActivity, "ShutDown"
End Sub
Public Sub StopClock()
On Error Resume Next
Application.OnTime NoActivity, "ShutDown", , False
End Sub
Workbook Module:
--------------------
Private Sub Workbook_Open()
Call StartClock
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
End Sub
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
If SuppressCalcEvent Then Exit Sub
Call StopClock
Call StartClock
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Call StopClock
Call StartClock
End Sub