Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Elliott Jones   on Dec 19 In MS Office Category.

  
Question Answered By: Pearl Garza   on Dec 19

Yes, create a User Form and have it do a 20 second count down. If you do
not click the button within  20 seconds  your automated program can start.
I did the same thing  for an automated Access program. The 20 second
count down form allows me to enter the program without having it run  so
I can do work on it, etc. Here is what you will need to count down for
20 seconds.

I use a non visible label to store the value when I click on the button.
So be sure to add twp labels and a button to your form. One label shows
the 20 second count down, the other is checked by the program to see if
the cancel button has been clicked.

'Allows user time  to cancel automated process
Dim vSecond As Variant
Dim newHour, newMinute, newSecond, waitTime As Variant
Dim i As Integer

lblStop.Caption = 0
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 20
vSecond = Second(Now())
waitTime = TimeSerial(newHour, newMinute, newSecond)

'This shows a count down timer on the form
i = 20
Do Until Time > waitTime
If lblStop.Caption = 1 Then 'Check hidden label to see if button was
clicked.
cmdStop.Caption = "Cancelled"
Exit Sub
End If
If vSecond = Second(Now()) Then 'The code runs faster than one second
so it takes a few iterations before one second actually passes.
Else
vSecond = Second(Now())
i = i - 1
lblTime.Caption = i
DoEvents
End If
Loop

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Procedure to abort automatic procedure? Or get search suggestion and latest updates.


Tagged: