Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am trying to setup procedures that perform some steps then run whichever macro is passed to them as a string argument the actual code leaving the STRING variable containing the macro and its arguments blank is: Sub SendMacroName() UseMacroStringToRunMacro STRING End Sub Sub UseStringToRunMacro(STRING) ....PERFORMS SOME STEPS... 'runs the macro represented in STRING Application.Run STRING End Sub This works fine in all but one case: when the macro to be run is in another file and has arguments. the actual string value that would work in such a case: Application.Run "FILE CONTAINING MACRO TO RUN.xls!MACRO TO RUN", "ARGUMENT 1", "ARGUMENT 2", etc i can give STRING that exact value by either of the following code, but neither work on the Application.Run STRING command STRING = """FILE.xls!MACRO""" & ", " & """ARGUMENT 1""" etc or STRING = """FILE.xls!MACRO"", ""ARGUMENT 1"" etc both result in the error message: method 'run' of object application failed if the macro to run were in the same file as the macro calling it [UseStringToRunMacro] the following would work: STRING = "'MACRO_NO_FILEPATH, "ARGUMENT 1", ETC '" [notice the string is bracketed by single quotes] but if the macro is in another file this doesn't work [and it is NOT b/c the file containing the macro isn't referenced, i tried "'FILE.xls!MACRO, "ARGUMENT 1", ETC '" [that produces a macro cannot be found error] if the macro to run were in another file but had no arguments the following works: STRING = "FILE.xls!MACRO" my guess is it has something to do with extra quotation marks around the string, or how to represent the file name when the macro has arguments. i think what may be happening is the STRING is interpreted as being the macro to run not as encompassing the name of the macro and each of its arguments. Thanks for your help, Ian |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Passing Arguments in Excell | Excel Worksheet Functions | |||
Passing arguments from VBA to DLL | Excel Programming | |||
passing arguments to events | Excel Programming | |||
Passing arguments to VB Function | Excel Programming | |||
Passing Arguments | Excel Programming |