zakasnak
Active Member
- Joined
- Sep 21, 2005
- Messages
- 308
- Office Version
- 365
- 2019
- Platform
- Windows
- MacOS
Do I put this in the worksheet tab "View Code"? That's where it would make sense to me....
I can't tell that it's working, tho.
I can't tell that it's working, tho.
Code:
Private Sub Workbook_Open()
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Dim Start, Finish, TotalTime, TotalTimeInMinutes, TimeInMinutes
Application.DisplayAlerts = True
TimeInMinutes = 30 '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
<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:place w:st="on">Loop</st1:place>
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
<o:p> </o:p>
Start = Timer
Do While Timer < Start + (5 * 60)
DoEvents
<st1:place w:st="on">Loop</st1:place>
Finish = Timer
TotalTime = Finish - Start
Application.DisplayAlerts = False
MsgBox "Excel will now close."
Application.Quit
End Sub