froggiebeckie
Board Regular
- Joined
- Sep 27, 2002
- Messages
- 87
I've got a couple of files posted on a shared drive, so multiple folks can access them.
One (Schedule) has code to save and close after 30 minutes, since folks are prone to open and then walk away from their desks.
It works fine.
But, when I tried to use the same code on the second file (MDL), it doesn't work.
Both are .xlsm files
Can anyone suggest what the issue may be?
Thanks,
BeckieO
Here are the codes for the 2 files.
MDL
'PLACE THIS CODE IN MODULE 1:
'******************************
Dim BootTime As Date
Sub StartTime()
'Start the Timer
BootTime = Now + TimeValue("00:30:10") 'Set your time here
Application.OnTime BootTime, "ShutDown"
End Sub
Sub ShutDown()
'At this point the main timer has elapsed.
Application.WindowState = xlMaximized 'Maximize window
Application.DisplayAlerts = False 'suppresses all messages about saving
ActiveWorkbook.Close savechanges:=True 'FALSE = changes are not saved
ThisWorkbook.Close
End Sub
Sub Disable()
'Stop the Timer
On Error Resume Next
Application.OnTime EarliestTime:=BootTime, _
Procedure:="ShutDown", Schedule:=False
End Sub
CLASS 1
Private Sub workbook_open()
End Sub
'start timer
Call StartTime
Private Sub workbook_beforeclose(canecel As Boolean)
'Stop the timer
Call Disable
End Sub
SCHED
'PLACE THIS CODE IN MODULE 1:
'******************************
Dim BootTime As Date
Sub StartTime()
'Start the Timer
BootTime = Now + TimeValue("00:30:10") 'Set your time here
Application.OnTime BootTime, "ShutDown"
End Sub
Sub ShutDown()
'At this point the main timer has elapsed.
Application.WindowState = xlMaximized 'Maximize window
Application.DisplayAlerts = False 'suppresses all messages about saving
ActiveWorkbook.Close savechanges:=True 'FALSE = changes are not saved
ThisWorkbook.Close
End Sub
Sub Disable()
'Stop the Timer
On Error Resume Next
Application.OnTime EarliestTime:=BootTime, _
Procedure:="ShutDown", Schedule:=False
End Sub
CLASS 1
Private Sub workbook_open()
End Sub
'start timer
Call StartTime
Private Sub workbook_beforeclose(canecel As Boolean)
'Stop the timer
Call Disable
End Sub
One (Schedule) has code to save and close after 30 minutes, since folks are prone to open and then walk away from their desks.
It works fine.
But, when I tried to use the same code on the second file (MDL), it doesn't work.
Both are .xlsm files
Can anyone suggest what the issue may be?
Thanks,
BeckieO
Here are the codes for the 2 files.
MDL
'PLACE THIS CODE IN MODULE 1:
'******************************
Dim BootTime As Date
Sub StartTime()
'Start the Timer
BootTime = Now + TimeValue("00:30:10") 'Set your time here
Application.OnTime BootTime, "ShutDown"
End Sub
Sub ShutDown()
'At this point the main timer has elapsed.
Application.WindowState = xlMaximized 'Maximize window
Application.DisplayAlerts = False 'suppresses all messages about saving
ActiveWorkbook.Close savechanges:=True 'FALSE = changes are not saved
ThisWorkbook.Close
End Sub
Sub Disable()
'Stop the Timer
On Error Resume Next
Application.OnTime EarliestTime:=BootTime, _
Procedure:="ShutDown", Schedule:=False
End Sub
CLASS 1
Private Sub workbook_open()
End Sub
'start timer
Call StartTime
Private Sub workbook_beforeclose(canecel As Boolean)
'Stop the timer
Call Disable
End Sub
SCHED
'PLACE THIS CODE IN MODULE 1:
'******************************
Dim BootTime As Date
Sub StartTime()
'Start the Timer
BootTime = Now + TimeValue("00:30:10") 'Set your time here
Application.OnTime BootTime, "ShutDown"
End Sub
Sub ShutDown()
'At this point the main timer has elapsed.
Application.WindowState = xlMaximized 'Maximize window
Application.DisplayAlerts = False 'suppresses all messages about saving
ActiveWorkbook.Close savechanges:=True 'FALSE = changes are not saved
ThisWorkbook.Close
End Sub
Sub Disable()
'Stop the Timer
On Error Resume Next
Application.OnTime EarliestTime:=BootTime, _
Procedure:="ShutDown", Schedule:=False
End Sub
CLASS 1
Private Sub workbook_open()
End Sub
'start timer
Call StartTime
Private Sub workbook_beforeclose(canecel As Boolean)
'Stop the timer
Call Disable
End Sub