excel vba question on Application.OnTime TimeValue

Discussion in 'Automated Trading' started by travis, Mar 27, 2014.

  1. travis

    travis

    Here they say:
    http://msdn.microsoft.com/en-us/library/office/ff196165(v=office.15).aspx

    My question is about this scope of the Application.OnTime method, which I use in my automated systems, where I am going from a daily schedule (starting them once a day) to a weekly schedule (starting them once a week).

    When they say that
    Code:
    Application.OnTime TimeValue("17:00:00"), "my_Procedure"
    will run a procedure at 5 P.M. does it mean the next instance of the clock being 17:00:00, whether today or tomorrow, or does it mean all future instances of 17:00:00?

    The fact that they have a method to cancel the Application.OnTime method doesn't help, because initially I thought: you have to cancel it because it means all future instances of the clock at 5 P.M., but it could also mean you use it to cancel the procedure before it happens for the first (and only) time.

    And if
    Code:
    Application.OnTime TimeValue("17:00:00"), "my_Procedure"
    will only run the procedure once, at the next instance of 5 P.M., which method could I use to run a procedure not just once but at 5 P.M. of every day of the week?
     
  2. travis

    travis

    OK, solved.

    Here they confirm that the "Application.OnTime TimeValue..." method only runs once. So it's just the next 5 PM and not all future instances of 5 PM. And they also explain how to execute a procedure at every future instance of 5 PM.

    http://www.mrexcel.com/forum/excel-...on-ontime-stops-executing-after-two-days.html