LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default PASSING MACROS WITH ARGUMENTS FROM OTHER FILES TO BE RUN

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Arguments in Excell UB Excel Worksheet Functions 3 February 13th 07 04:08 PM
Passing arguments from VBA to DLL [email protected] Excel Programming 10 August 18th 06 09:08 AM
passing arguments to events Paul Excel Programming 2 May 24th 06 03:18 PM
Passing arguments to VB Function Tom Excel Programming 1 March 29th 06 01:19 AM
Passing Arguments Grant Reid Excel Programming 8 May 24th 04 01:39 PM


All times are GMT +1. The time now is 03:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"