Results 1 to 7 of 7

Thread: I want to trigger a sub routine every minute.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2017
    Posts
    72

    I want to trigger a sub routine every minute.

    I have been using "Application.OnTime" to trigger a different sub according to a given hour.
    You can can use the same method or some other code if you like.
    Thanks....

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: I want to trigger a sub routine every minute.

    Are you asking a question? If you are, then of course you would use a Timer Control.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: I want to trigger a sub routine every minute.

    I have no idea what 'Application.OnTime' refers to. As far as I can see, there is no such member in the .NET Framework.

    Assuming Windows Forms, you would normally add a Timer component (not control) to your form in the designer and set its Interval to 1000 milliseconds. It will then raise its Tick event approximately every second after you call Start or set Enabled to True.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2017
    Posts
    72

    Re: I want to trigger a sub routine every minute.

    Actually, I just finished the code a few seconds ago and I did use Application.OnTime.
    It was a lot easier than I thought. It turns out to be:

    Application.OnTime Now + TimeValue("00:00:01"), "EventMinutesMacro"

    I did not realize that one could add time to Now.
    The use of a VB timer does not seem to work in Excel, which I forgot to mention. ):

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: I want to trigger a sub routine every minute.

    That code is some flavour of VB but it's certainly not VB.NET, so please post in the correct forum in future.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2017
    Posts
    72

    Re: I want to trigger a sub routine every minute.

    Quote Originally Posted by jmcilhinney View Post
    That code is some flavour of VB but it's certainly not VB.NET, so please post in the correct forum in future.
    Ok, I thought Excel Developer was VB.net so I guess I stand corrected.
    Mea Culpa.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: I want to trigger a sub routine every minute.

    You must have missed the Office Development forum. Also, whatever forum you post in, please provide ALL the relevant information. Even in Office Development, the fact that you're programming for Excel specifically is relevant.

Posting Permissions

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



Click Here to Expand Forum to Full Width