Results 1 to 2 of 2

Thread: [RESOLVED] Ontime from class module

  1. #1

    Thread Starter
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Resolved [RESOLVED] Ontime from class module

    Does anybody know how to run a macro using OnTime in Excel VBA that's in a class module rather than in a standard code module?
    Or, alternatively, to pass parameters to the proc?

    In summary, I am looking to run scheduled tasks out of a class module. I can run a given proc, but if there are multiple instances of the class active then the proc won't know which one has called it. So either I need to tell OnTime to call a proc within its own class or I need to pass a parameter to the proc to tell it which instance of the class did the scheduling.
    I could use a dictionary to look up the schedule time and affiliate that to a class ID, but I'd rather do something a bit more concrete, ie definitively associate a specific class instance with the code that runs.

    The only other option I can think of is to create it in VSTO and run it through there.

    Thoughts?
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  2. #2

    Thread Starter
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Ontime from class module

    Found an answer. You call the macro in single quotes within the double quotes, and double-double the parameter.

    So:

    Application.OnTime Now()+TimeValue("00:00:05"), " ' MyMacro ""MyParameter"" ' "
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

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