O
ordnance1
I found this code below on-line (can not remember where) but just wondering
if someone could tell be how to stop the timer? I want the user to have the
option to stop the timer if necessary.
Option Explicit
Sub Autpen()
'
' AutoRun Macro
' Macro recorded 2/3/2001 by Patrick C. Simonds
'
bSELCTIONCHANGE = False
Events.Enable_Events
Dim Start, Finish, TotalTime, TotalTimeInMinutes, TimeInMinutes
Application.DisplayAlerts = True
TimeInMinutes = 15 'Timer is set for 180 minutes; change as needed.
If TimeInMinutes > 5 Then
TotalTimeInMinutes = (TimeInMinutes * 60) - (5 * 60)
Start = Timer
Do While Timer < Start + TotalTimeInMinutes
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
Application.DisplayAlerts = False
'msgbox "This file has been open for " & TotalTime / 60 & " minutes. You
have 5 minutes to save before Excel closes."
End If
Start = Timer
Do While Timer < Start + (5 * 60)
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
Application.DisplayAlerts = False
'msgbox "Excel will now close."
ThisWorkbook.Close True
End Sub
if someone could tell be how to stop the timer? I want the user to have the
option to stop the timer if necessary.
Option Explicit
Sub Autpen()
'
' AutoRun Macro
' Macro recorded 2/3/2001 by Patrick C. Simonds
'
bSELCTIONCHANGE = False
Events.Enable_Events
Dim Start, Finish, TotalTime, TotalTimeInMinutes, TimeInMinutes
Application.DisplayAlerts = True
TimeInMinutes = 15 'Timer is set for 180 minutes; change as needed.
If TimeInMinutes > 5 Then
TotalTimeInMinutes = (TimeInMinutes * 60) - (5 * 60)
Start = Timer
Do While Timer < Start + TotalTimeInMinutes
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
Application.DisplayAlerts = False
'msgbox "This file has been open for " & TotalTime / 60 & " minutes. You
have 5 minutes to save before Excel closes."
End If
Start = Timer
Do While Timer < Start + (5 * 60)
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
Application.DisplayAlerts = False
'msgbox "Excel will now close."
ThisWorkbook.Close True
End Sub