View Single Post
  #1   Report Post  
no1jimmyman no1jimmyman is offline
Junior Member
 
Posts: 3
Default 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,