ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   filename!macroname as variables (https://www.excelbanter.com/excel-discussion-misc-queries/269549-filename-macroname-variables.html)

no1jimmyman

filename!macroname as variables
 
Hello everyone,

I know when you call a macro which lies in an external excel file, you reference it by: filename!macroname, so it will look like something below:

oExcel.Run "'D:\myExcelFile.xls'!myMacro"

Now i want to put the file name and macro name into a variable, as it can change, but i need to know the SYNTAX to do this; sample code is below:

Dim myFileName As String
Dim myMacro As String

myFileName = "'D:\myExcelFile.xls'"
myMacro = "myMacro"

oExcel.Run THEN I DONT KNOW THE SYNTAX, eveything i tried hast worked.

Thanks in advance,


All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com