I’m attempting to use VBAs Application.OnTime method to call a function every minute. The code that I have so far is as follows.
Defined globally:
Dim alertTime As Date
In one of the first methods that gets called:
alertTime = Now + TimeValue("00:00:10")
Application.OnTime alertTime, "myFunc"
In the myFunc method:
alertTime = Now + TimeValue("00:00:10")
Application.OnTime alertTime, "myFunc"
10 seconds after I’ve run the macro I get a warning dialog telling me Error loading DLL. I’ve not specified any other DLLs to be loaded in the myFunc method so that doesn’t seem like it would be the problem. Is there an additional library I need to include to use Application.OnTime?
Shouldn’t be, is myFunc in the same namespace though? If myFunc is not located in your namespace, or not created yet as a macro, by default Application.OnTime will look for a module named myFunc instead.