Results 1 to 2 of 2

Thread: OnTime

  1. #1
    New Lounger
    Join Date
    Jan 2001
    Thanked 0 Times in 0 Posts


    A coworker recently sent me web posting she had found that suggested an alternative to AutoSave. The article suggested putting these three macros in your Word documents, which will do a real save every ten minutes.

    Sub AutoOpen()
    End Sub

    Sub WordSaver()
    Application.OnTime When:=Now + TimeValue("00:10:00"), Name:="Saver"
    End Sub

    Sub Saver()
    End Sub

    I have no experience with the OnTime method, but I have enough experience with Word to be suspicious of it. As far as I know, VBA is not a threaded environment. But here is a method that is clearly running within a thread.

    As soon as I saw this code my mind flashed with images of Word being locked up and users enraged by the loss of data.

    Does anyone more knowledgeable than me foresee any real dangers with this, or are my fears just mirages?


  2. #2
    3 Star Lounger
    Join Date
    May 2001
    Burlington, KS, USA
    Thanked 0 Times in 0 Posts

    Re: OnTime

    I do not foresee any real dangers running this macro. The OnTime method merely runs a background timer (the same as the OnTime command in WordBasic). If Word is occupied at the specified time -- for example, if a dialog box is displayed or Word is performing a large sort operation -- the macro runs as soon as Word is idle. And if the document is large, of course, there will be delays while it is being saved every 10 minutes.

    The only caveat is that only one OnTime macro can be ran at a given time. If you start another timer before an existing timer runs, the existing timer is canceled.

    There are other methods to suspend execution of a macro for a length of time. Check Article #Q212667 in the Microsoft Knowledge Base.
    The postings on this site are my own and do not necessarily represent the position or opinion of WCNOC.

Posting Permissions

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