I\'ve run into this error when trying to make a stopwatch timer in Excel. Here\'s a simple test code. Create an empty Excel workbook with a button. And assign a macro to it:
I found using OnTime with current time will cause your code to run on the main thread immediately or fail. I found this better because you only need to trap the OnTime error.
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal
dwTimer As Long)
On Error GoTo BeforeExit
Application.OnTime Now, "updateWorksheet"
BeforeExit:
End Sub
Sub updateWorksheet
Range("A1") = "test"
End Sub