Reputation: 396
I have a macro enabled excel file in which I am trying to create a macro to run functions every 2 minutes.
The following is my code:
Sub macro123()
Application.SendKeys ("%{A}")
Application.SendKeys ("R")
Application.SendKeys ("A")
Call test
End Sub
Sub test()
Application.OnTime Now + TimeValue("00:02:00"), "macro123"
End Sub
The macro123 gets executed the first time I run it. After 2 minutes it tried to run it again, that's when I am getting the following error.
[![enter image description here][1]][1]
The macro settings seem to be greyed out, probably due to domain settings of organization?
[![enter image description here][2]][2]
Is there any other way for me to execute those statements every n minutes?
Upvotes: 2
Views: 484
Reputation: 29352
If your macro is in the code module ThisWorkbook
, then you should specify it including the code module's name.
Try this:
Application.OnTime Now + TimeValue("00:02:00"), "ThisWorkbook.macro123"
' ^^^^^^^^^^^^^^
Upvotes: 2