+ Reply to Thread
Results 1 to 8 of 8

Canceling Application.ontime loops

  1. #1
    Registered User
    Join Date
    09-23-2013
    Location
    Gold Coast, Australia
    MS-Off Ver
    2010
    Posts
    50

    Canceling Application.ontime loops

    Hey guys,

    I didn't realise that when you set an Application.ontime loop it does NOT stop simply by closing the document. I've got some funky stuff going on as a result, with spreadsheets popping up all over the place and generating backups when they haven't been active.

    So how can I stop these already-looping macros from triggering, and ensuring I never code this way again?!

  2. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Canceling Application.ontime loops

    Here's an example of a Timer being Started and also Stopped..

    In the example below. the Sub StopTimer is setting the Schedule to False.
    You could call that from a button or put it in the Workbook Close event..

    Please Login or Register  to view this content.

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Canceling Application.ontime loops

    To stop the current scheduled macros, simply close the whole application and restart it.

    In the example posted by apo there is a missing declaration for dTime which must be module-level or Public and not within a routine.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Canceling Application.ontime loops

    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  5. #5
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Canceling Application.ontime loops

    Izandol is right..

    Put this at the top of the Module for my example..
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-23-2013
    Location
    Gold Coast, Australia
    MS-Off Ver
    2010
    Posts
    50

    Re: Canceling Application.ontime loops

    Thanks for the feedback guys, much appreciated.

    Izandol, I'm finding that when x & y workbooks are open, z workbook (which in this case is an old unused workbook that had an Application.ontime command set without code to stop the time) is opening itself randomly as the timers are still active.

    I wouldn't know how many files I've set a number of timers to activate, without realising I needed to also code them to stop! I guess one solution is to just delete the offending files, but should I need to keep them, is there a way to generically kill all timers that were previously set (or is it just a matter of modding the code and implementing the StopTimer() function?)

    Cheers!

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Canceling Application.ontime loops

    Closing the application clears any timers. You may then open the workbooks with macros disabled and modify the code as required.

  8. #8
    Registered User
    Join Date
    09-23-2013
    Location
    Gold Coast, Australia
    MS-Off Ver
    2010
    Posts
    50

    Re: Canceling Application.ontime loops

    Thank you! I guess that the PCs that have been having this issue have always had Excel open with one spreadsheet or another - therefore the application had never been closed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Application.OnTime Help
    By bs04do in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2013, 09:06 AM
  2. [SOLVED] Help with Application.OnTime (was Application.Wait Now)
    By Walter12 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-29-2012, 01:18 PM
  3. use of Application.ontime
    By katto01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2012, 09:58 PM
  4. Application.OnTime
    By sportsguy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2008, 02:09 PM
  5. [SOLVED] Help with Application.OnTime
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2006, 01:10 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1