Hi all,
I have just added some code to make my workbook close after it has been inactive for 5 minutes...this works fine except it opens itself up again after 5 minutes.
If I select 'Enable Macros' it closes immediately and if not, it will stay open.
Here is all of the code I put in for the auto shut down:
ThisWorkbook:
Private Sub Workbook_Open()
dTime = Time
On Error Resume Next
Application.OnTime dTime + TimeValue("00:05:00"), "CloseMe"
On Error GoTo 0
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
Application.OnTime dTime + TimeValue("00:05:00"), "CloseMe", , False
dTime = Time
Application.OnTime dTime + TimeValue("00:05:00"), "CloseMe"
On Error GoTo 0
End Sub
Module1:
Public dTime As Date
Sub CloseMe()
Application.StatusBar = "Inactive File Closed: " & ThisWorkbook.Name
ThisWorkbook.Close SaveChanges:=True
End Sub
Sub Message_Close()
Response = MsgBox("This file will automatically save and close after 5 minutes of inactivity", vbInformation, "This is a message")
End Sub
Any ideas what is going on?
Bookmarks