Running a macro in another WB

O

Otto Moehrbach

Excel XP & Win XP
I have files AAA.xls and BBB.xls open.
I am running code that is in AAA.xls.
I want to run macro MyProc that is in BBB.xls.
For that I use this code:
Application.Run "BBB.xls!MyProc"
I get the error that the macro cannot be found.
I checked the file and macro names and they are right.
Is the Application line syntax not right?
Thanks for your time. Otto
PS: The 2 files reside in different folders. Could that be a problem?
 
M

Mark Dullingham

Create a Personal.xlsb, you can choose this when you record a macro, then
place the code in a module in the Personal.xlsb and use the following

Application.Run ("Personal.xlbs!MyProc")

hth

Mark
 
O

Otto Moehrbach

Mark
Thanks for responding. Putting the target macro in the Personal.xls
file is just moving it from one open file to another open file. My problem
is that the macro cannot be found regardless of what other workbook it's in.
I tried putting the target workbook and macro in parentheses like you
did but that didn't work either. Otto
 
M

Mark Dullingham

The personal work book is different as it has a XLSB extension and is
specifically designed to allow macro's to be called from any open workbook,
it is not an actual woorkbbok in the same way as your AAA and BBB are.

I have tested this using a simple column hide macro starting with your code
and ending up with the one I posted and it works.

You could, of course, just have the macro in both workbooks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top