Run macro in an external access db from current access db

S

skunjur

Hi Guys,

Is there a code to run a macro I have in an external database from my
current database. I tried to use the RunMacro method after connecting to the
external database and it wouldn't work.

Here is the code I am using. Any help would be greatly appreciated.

Sham

Set CubeCalcDb = OpenDatabase(FileName)

With CubeCalcDb

DoCmd.RunMacro "003_Calculate_Cube"

End With
 
M

Marshall Barton

skunjur said:
Is there a code to run a macro I have in an external database from my
current database. I tried to use the RunMacro method after connecting to the
external database and it wouldn't work.

Here is the code I am using. Any help would be greatly appreciated.

Set CubeCalcDb = OpenDatabase(FileName)

With CubeCalcDb

DoCmd.RunMacro "003_Calculate_Cube"

End With


AFAIK, there is no way to run a macro in another db. In
addition, OpenDatabase does not expose anything in a
database beyond its DAO objects, which does not include
macros or VBA code.

If you convert the macro to a VBA procedure and reference
the other db as a library. Then you can use the procedure
as if it were in your regular db.

For more complex situations, you might need to explore using
Automation.
 

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