+ Reply to Thread
Results 1 to 3 of 3

Auto kill a prosedure after a certain time

  1. #1
    Registered User
    Join Date
    04-30-2015
    Location
    Amsterdam
    MS-Off Ver
    2013
    Posts
    12

    Auto kill a prosedure after a certain time

    Hi there,

    I have a macro which auto runs via windows sheduler. There are a couple of loops in the macro. Is it possible to automatically stop / kill the macro whem by accident an infinite loop takes place? This hasn't happend yet, but just to be sure. For example, stop running when it runs for more then ten minutes.

    If this is possible, what code shoud I use?

    Thank you!!

    Adrian

  2. #2
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Auto kill a prosedure after a certain time

    You could make it take note of the time at the start of the code and then put in the condition of the loops something like:

    Please Login or Register  to view this content.
    !If all your troubles are solved, then so is the thread. Show this by marking it so using thread tools at the top of the page.
    If I helped do this, then please show your appreciation by awarding rep points.
    <------ Button for that is over there

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Auto kill a prosedure after a certain time

    1. Put a DoEvents statement someplace where it executes often enough. After that statement, test a Boolean variable (like "bStop") to see if you should quit.

    2. Before the routine starts, use OnTime to schedule a routine that sets bStop True. That routine could also be triggered by pressing a button.

    The DoEvents statement will also make the code responsive to Ctrl+Break
    Last edited by shg; 07-30-2015 at 10:28 AM.
    Entia non sunt multiplicanda sine necessitate

+ 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. Replies: 1
    Last Post: 06-11-2015, 11:12 PM
  2. Replies: 1
    Last Post: 06-11-2015, 10:58 PM
  3. Kill command/ Time bomb/ permanently delete
    By ThomasAnthony in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-06-2014, 08:29 AM
  4. Run-time error '70' when using "kill" in VBA
    By toxigal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-15-2013, 01:31 PM
  5. Setting a time kill/delete by set date in spreadsheet
    By exempt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2011, 09:56 PM
  6. Auto Sort, Auto Lock, Auto Date & Time Stamp
    By suehatesyou in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2010, 02:57 PM
  7. [SOLVED] On time kill
    By Antonio in forum Excel General
    Replies: 4
    Last Post: 06-08-2006, 09:20 AM

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