0

For context, I'm aware of the Application.Run syntax, but for whatever reason I can't get it to work for the specific macro name I'm trying to run.

Example, this syntax works (if I rename the macro to 'AR'):

Application.Run "AB.xlsm!AR"

But this syntax generates a RunTime 1004 error:

Application.Run "AB.xlsm!AnaplanRefresh"

What is it about my camelcase macro name that throws this off?

  • The workbook name needs to be in single quotes, like so `Application.Run "'Another Workbook.xlsm'!NameOfMacro"` – Nathan_Sav Jan 29 '20 at 18:49
  • The single quotes are only necessary when the workbook name has a space in it, but for kicks I did it anyway and it generates the same error: Application.Run "'AB.xlsm'!AnaplanRefresh" – Samuel Carson Jan 29 '20 at 18:53
  • 1
    The camel case shouldn't be an issue - the linked dupe has camel case and has no issue. I'd check your spelling as the next likely culprit. – BigBen Jan 29 '20 at 18:55
  • I can literally copy/paste the macro name and it doesn't work. Needless to say it isn't a spelling issue. – Samuel Carson Jan 29 '20 at 19:13
  • I don't know why you closed this as the question you linked doesn't help my use case. I'm literally using all the right syntax and it doesn't function. I can rename the macro to 'AnaplantRefresh' and it works, or any other name I can think up, but renaming isn't an option for my use case. Might it have anything to do with the Module Name being identical in this context to the Sub name? – Samuel Carson Jan 29 '20 at 19:33
  • 1
    What is the text of the error message you're getting? Are both called working/non-working Subs in the same module? "Might it have anything to do with the Module Name being identical in this context to the Sub name?" - absolutely: change one of those. – Tim Williams Jan 29 '20 at 19:39
  • So I've tested it and whenever the Module name and Sub name are identical the Application.Run syntax doesn't work. Unfortunately my use case involves opening a ton of workbooks in which the Module and Sub names are identical. Is it possible to rename the Module via my VBA code before using the Application.Run? – Samuel Carson Jan 29 '20 at 19:44
  • 1
    Try: `Application.Run "AB.xlsm!AnaplanRefresh.AnaplanRefresh"` – Tim Williams Jan 29 '20 at 19:47
  • Yeah tried that earlier and no go. Good news is I can technically rename the Module's programmatically if I enable a Trust Center setting and use ```Workbooks("AB.xlsm").VBProject.VBComponents("AnaplanRefresh").Name = ``` – Samuel Carson Jan 29 '20 at 19:55

0 Answers0