Hi Everyone! I've been a fan of this site for a long time, but for some reason have never registered. I'm now here posing a problem that I'm having that I'm really hoping has an obvious solution I may have overlooked.
Problem: OnTime method will immediately execute the indicated function without waiting for the specified time and, upon exiting the called function and returning to the function that called the OnTime method, an error is thrown. The specific error is very generic ("Run-time error '1004': Application-defined or object-defined error").
How it's setup: I have a sub calling a very simple OnTime method and a function that is called from the OnTime method. Again, trying to keep this as simple as possible. Here is what it looks like:
Public Sub test()
Application.OnTime Now + TimeValue("00:00:10"), SampleFunction
End Sub
Private Function SampleFunction()
MsgBox "This function is now being executed"
End Function
I execute the sub test(), it hits the OnTime method and immediately afterward the SampleFunction() is called. After that function exits the error is thrown. If I click "Debug" I'm taken directly back to the OnTime method. If I end, nothing further happens.
Has anyone ever seen this before? I've used the OnTime method in the past and it's worked just fine - now it won't work at all
. Any and all help is most appreciated! And please let me know if I can provide further details to assist. By the way, I'm using Office 2010 running on Windows 7 and this error is happening for me both at home and at work leading me to believe that I'm doing something terribly wrong...
Bookmarks