Link to home
Start Free TrialLog in
Avatar of octi
octi

asked on

Application OnTime event

Is the Application.OnTime event valid in Visual Basic? Or could be used only in VBA? I get the error message 'Macro "my_procedure" not found.' Even if I put the "my_procedure" in a different module, the error message is the same. Any solutions to this?
Thanks
Avatar of WolfgangKoenig
WolfgangKoenig

When you put "my_procedure" in a different module you
must reference the module name of the different module:
"my_procedure" in a different module:

Application.OnTime Now + TimeValue("00:00:15"), "ModuleName.meine_Prozedur"

Best Regards
WoK
ASKER CERTIFIED SOLUTION
Avatar of kdg2000
kdg2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nitin Sontakke
Application is a generic object name, so its context changes according to its instantiation. Unless you are using automation, such an object doesn't exist in VB, forget the event.

So, make sure that Application object has appropriate context. You didn't mention from which Application did you imported the Macro.

If i am not clear, please give more info as what you are attempting to do. So that i will be able to tell more details.

But in short, Application.OnTime event is NOT in VB. It MIGHT be used, provided an appropriate context to Application object is available in VB.

Please give more details, though.
Avatar of octi

ASKER

Details:
I would like to run a procedure in Visual Basic (The result will be an exe file) at a certain time (8:00 AM for ex) using the Application objects OnTime event. This is the simplest one. The event occurs (becasuse I get the mentioned messege right on scheduled time) at the given time, but the procedure is not found.
Your procedure is defined in your VB exe project ?
Avatar of octi

ASKER

WolfgangKoenig>
Yes, my procedure is defined in the exe project.
In your VB exe Project you have an handle to the VBA
application and then you call:

Application.ontime ....

Then VBA finds only VBA side defined macro procedures.
Not the functions defined in VB.

WoK

I agree with WolfgangKoenig.
If you want to run code from VB (Not vba) at certain time, use, inside VB, a timer control or api's SetTimer and KillTimer.