Call / Run a Macro from another Workbook

Irish_Griffin

Board Regular
Joined
Jan 16, 2009
Messages
138
Hi Everyone,
Here is an interesting problem.

Within VBA, I want to open an existing workbook and call/run macros found in this newly opened workbook.

With searching, I found the following code to run a macro from a different workbook :
Code:
Dim File_Path as string
Dim File_Name as string

File_Path = "C:\test.xls"
File_Name = "test.xls"

Workbooks.OpenText Filename:=File_Path

Application.Run File_Name & "!macro_name_here"

My problem is this :
I need to pass variables into the macro found in the other workbook

thus the following code does not work :
Code:
Application.Run File_Name & "!macro_name_here(string_var, boolean_var)"

Is there a solution ???

Many Thanks,
Griff
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Did you try eg?

Code:
Application.Run File_Name & "!macro_name_here(string_var, boolean_var)", Arg1, Arg2

where Arg1 and Arg2 are variables containing arguments 1 and 2.
 
Upvote 0
Solved, I was just a couple Googles away ;)

Code:
Application.Run File_Name & "!macro_name_here", string_var, Boolean_Var


Friday is Tomorrow !!!! WOOT for the weekend !!!

Peace,
Griff
 
Upvote 0

Forum statistics

Threads
1,224,532
Messages
6,179,388
Members
452,908
Latest member
MTDelphis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top