ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close workbook timer with notification (https://www.excelbanter.com/excel-programming/421349-close-workbook-timer-notification.html)

James

Close workbook timer with notification
 
hi all,
Is there a way to close a workbook if it has been at idle for a certain
amount of time? Id like it to also display that its going to close in
20...19....18....17...etc (a countdown) and an option to keep it open. The
idle criteria should reset if a combo box on a sheet has been clicked (or got
focus) or if another sheet has been activated. thanks for the help

Brotha Lee

Close workbook timer with notification
 
James,

You could use the following code:

shutdowntime = 5 'Time in second for shutdown
currenttime = timer

While timer <= shutdowntime + currenttime
DoEvents
'Update the statusbar to show how many second remain. Could
'also use a userform to show the remaining time
Application.StatusBar = Round(5 - (timer - currenttime), 0) & _
" seconds left before closing down"
Wend


If MsgBox("Close file", vbYesNo, "Auto shutdown") = vbYes Then
'Code to close
.....................
'Reset the statusbar
Application.StatusBar = False
Else
'Code to keep open
..........................
'Reset the statusbar
Application.StatusBar = False
End If
End Sub

"James" wrote:

hi all,
Is there a way to close a workbook if it has been at idle for a certain
amount of time? Id like it to also display that its going to close in
20...19....18....17...etc (a countdown) and an option to keep it open. The
idle criteria should reset if a combo box on a sheet has been clicked (or got
focus) or if another sheet has been activated. thanks for the help



All times are GMT +1. The time now is 05:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com