Hi,
i'm using code to save and close my workbook after being idle for 15 minutes.
instead of saving and closing on its own, the excel window starts flashing and a pop up message appears "running test 15". Once I click 'Ok' on this message, then the workbook saves and closes.
Is there a way to avoid this message?
workbook:
Option Explicit
Private Sub Workbook_Open()
Sheets("Home Page").Activate
Sheets("History Maintenance").Protect "123steel"
Sheets("History Contractors").Protect "123steel"
Sheets("Current Maintenance").Protect "123steel"
Sheets("Current Contractors").Protect "123steel"
Sheets("Read Only").Protect "123steel"
EditDate = Now
Application.OnTime Now + TimeValue("00:15:00"), "TestForUpdates"
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
EditDate = Now()
End Sub
module:
Option Explicit
Public EditDate As Date
Sub TestForUpdates()
MsgBox "Running Test " & Minute(Now - EditDate)
If EditDate <= Now - TimeValue("00:15:00") Then
If ThisWorkbook.Saved = False Then
ThisWorkbook.Save
End If
Application.DisplayAlerts = False
ThisWorkbook.Close
Else
Application.OnTime Now + TimeValue("00:15:00"), "TestForUpdates"
End If
End Sub
Bookmarks