RE: Countdown timer
- From: Jock <Jock@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 3 May 2007 06:08:00 -0700
All help is very much appreciated.
--
tia
Jock
"JLatham" wrote:
Let me examine/test things a little and I'll get back with you. I want to.
make sure that what I do fits in with what you have already in place.
"Jock" wrote:
JL, not sure how to aproach this as I would like the 'timer' to appear on the
open workbook and be linked to the code checking for inactivity (below). I'm
not that well up on codes and how to modify them to achieve the desired
results. Any help appreciated.
Private Sub Workbook_Open()
RunTime = Now() + TimeValue("02:01:00")
Application.OnTime RunTime, "SaveAndCloseMe"
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.OnTime RunTime, "SaveAndCloseMe", , False
RunTime = Now() + TimeValue("02:01:00")
Application.OnTime RunTime, "SaveAndCloseMe"
End Sub
This saves and closes the workbook after 2 hrs and 1 minute of inactivity.
--
tia
Jock
"JLatham" wrote:
Jock, I wrote it as a 'stand-alone' Sub so that I could test it, but I
actually envision it as being part of the routine you're using now that
closes the book due to inactivity. Or you can put it into your book as is,
and just call it from within another routine, such as the one you have
checking for inactivity already.
"Jock" wrote:
Thanks, I'll give it a try
--
tia
Jock
"JLatham" wrote:
Yes, You can probably incorporate this into the routine you have set up to
check for inactivity. Here's routine that puts 60 seconds on the clock, and
then displays time remaining in C1 of the active ***.
Sub DisplayTimeRemaining()
'displays time remaining in seconds
Const TimeAllowed = 60 ' 60 second countdown
Dim TimePassed As Long
Dim StopTime As Long
Dim TimeRemaining As Long
'set up the countdown
TimePassed = Timer
StopTime = TimePassed + TimeAllowed
TimeRemaining = TimeAllowed
'start the countdown
Do While Timer <= StopTime
If Timer > TimePassed + 1 Then
TimeRemaining = TimeRemaining - 1
Range("C1") = TimeRemaining
TimePassed = Timer
End If
DoEvents
Loop
Range("C1") = 0
End Sub
"Jock" wrote:
I have used vba code to automatically save then close an pen workbook which
has had no activity for a specified period of time. Is it at all possible to
have a countdown clock displayed is a cell in the workbook indicating to the
user how long is left before shut down?
--
tia
Jock
- Follow-Ups:
- RE: Countdown timer
- From: JLatham
- RE: Countdown timer
- References:
- RE: Countdown timer
- From: Jock
- RE: Countdown timer
- From: JLatham
- RE: Countdown timer
- From: Jock
- RE: Countdown timer
- From: JLatham
- RE: Countdown timer
- Prev by Date: Trouble with copy to newly created ***
- Next by Date: Re: Trouble with copy to newly created ***
- Previous by thread: RE: Countdown timer
- Next by thread: RE: Countdown timer
- Index(es):