Consulting

Results 1 to 4 of 4

Thread: repeate an action

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    repeate an action

    hello
    the following macro will save and close all open workbooks except the active workbook within 15 seconds.how do i make it repeate it's action?.
    namely- how do i create my on autosave mechanism.
    [VBA] Sub doit2()
    Dim dnext As Date
    dnext = TimeValue("00:00:15")
    Application.OnTime Now + dnext, "closeallbut"
    End Sub
    [/VBA]
    thanks
    Last edited by malik641; 12-05-2005 at 11:58 AM. Reason: Needed some VBA tags :-)
    moshe

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Just call the same sub with ontime. So it will keep calling itself.

    [vba]
    Option Explicit

    Sub a()

    MsgBox "Hi"
    Application.OnTime Now + TimeSerial(0, 0, 2), "a"

    End Sub
    [/vba]

  3. #3
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    a question

    hello
    could you be more specific.your macro do not work.
    thanks
    moshe

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You can just copy my code to a module in the VBE, then run it. The message box will keep poping up every 2 seconds.

Posting Permissions

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