N
Neil Holden
Hi all gurus please help.
I have a windows schelduler to open at a certain time and when the cells
have been updated the file closes.
The problems i'm having it the file stays open and i have to manually close
the open file on a weekly basis, the cells are not updated either?
Please see my code below:
Private Changed As Boolean
Private Sub Workbook_Open()
'start with the workbook showing unchanged
Changed = False
' create our shutdown timer
Application.OnTime Now + TimeValue("00:00:10"),
procedure:="ThisWorkbook.Auto_Close"
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)
'if something is changed then restart the timer
Changed = True
End Sub
Private Sub Auto_Close()
'if no changes detected then save and close
If Changed = False Then
ThisWorkbook.Close SaveChanges:=True
End If
Changed = False
'cancel the timer
Call Application.OnTime(Now + TimeValue("00:00:15"),
"ThisWorkbook.Auto_Close")
End Sub
I have a windows schelduler to open at a certain time and when the cells
have been updated the file closes.
The problems i'm having it the file stays open and i have to manually close
the open file on a weekly basis, the cells are not updated either?
Please see my code below:
Private Changed As Boolean
Private Sub Workbook_Open()
'start with the workbook showing unchanged
Changed = False
' create our shutdown timer
Application.OnTime Now + TimeValue("00:00:10"),
procedure:="ThisWorkbook.Auto_Close"
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)
'if something is changed then restart the timer
Changed = True
End Sub
Private Sub Auto_Close()
'if no changes detected then save and close
If Changed = False Then
ThisWorkbook.Close SaveChanges:=True
End If
Changed = False
'cancel the timer
Call Application.OnTime(Now + TimeValue("00:00:15"),
"ThisWorkbook.Auto_Close")
End Sub