Consulting

Results 1 to 4 of 4

Thread: Solved: Repeating code at intervals

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Solved: Repeating code at intervals

    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?

    [VBA]
    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
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You can just have the macro Check1 call itself instead of having a second sub. But there shouldn't be any problems.

  3. #3
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks Jacob.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •