views:

1275

answers:

1

Hello,

Application.Run "MyWorkBook.xls!Macro1"

will work (run the macro called Macro1 in the MyWorkBook.xls file)

Application.Run "My Work Book.xls!Macro1"

will not (if the workbook name contains spaces, Excel says "the macro cannot be found").

I just spent hours figuring out that it's the spaces causing this problem...

Is there a way around this without renaming the file?

+3  A: 

Use single quotes surrounding the filename:

Application.Run "'My Work Book.xls'!Macro1"
e.James
Brilliant, thanks!
Laurent
My pleasure. I've been there `:)`
e.James