PDA

View Full Version : Solved: Repeating code at intervals



mdmackillop
11-25-2004, 11:59 AM
Hi all,
I posted this in "another place" to repeat some code at intervals. Is there any potential memory or other problem in looping code like this?


Private Sub Document_Open()

Application.OnTime When:=Now + TimeValue("00:00:05"), _
Name:="Check1"

End Sub


Sub Check1()
Application.OnTime When:=Now + TimeValue("00:00:05"), _
Name:="Check2"
If ActiveDocument.Saved = False Then
MsgBox Now()
ActiveDocument.Save
End If
End Sub

Sub Check2()
Application.OnTime When:=Now + TimeValue("00:00:05"), _
Name:="Check1"
If ActiveDocument.Saved = False Then
MsgBox Now()
ActiveDocument.Save
End If
End Sub

Jacob Hilderbrand
11-25-2004, 12:06 PM
You can just have the macro Check1 call itself instead of having a second sub. But there shouldn't be any problems.

mdmackillop
11-25-2004, 12:41 PM
Thanks Jacob.

Jacob Hilderbrand
11-25-2004, 03:51 PM
You're Welcome :)

Take Care