Application.Run Method

  • Thread starter Mark Worthington
  • Start date
M

Mark Worthington

I have been using the Application.Run method for a long time, and
thought I was familiar with its syntax, namely :

Application.Run AnotherSub
Application.Run ("Add-In Name!Macro Name")
Application.Run "'Some book.xls'!TheMacro"

However, I need to pass some arguments to another procedure, and the
only way I can get it to work is as follows (transferring a string
variable from the 1st sub to the called sub) :

Application.Run "AnotherSub", My_Procedure_Name

It fails if I try what I expected, ie with the ( )

Application.Run ("AnotherSub", My_Procedure_Name)

But works if I use

Result = Application.Run ("AnotherSub ", My_Procedure_Name)

Now this isn't too important (hey, it works after I spent a lot of
time experimenting and searching the Goggle Groups), but am I missing
something? The Excel help indicates that the ( ) are required.

Any comments would be welcome in order to broaden my mind!

Regards,

Mark
 
K

Kevin Beckham

Try it without the brackets
I use the following line of code to run a macro in another
workbook.

Application.Run "ACM_Excel_Interface.xls!
UpdateCallerList", ThisWorkbook.Name

so passing the calling workbook's name to the
UpdateCallerList procedure. No value is returned.

Kevin Beckham
 
T

Tom Ogilvy

You are misreading the help.

VBA syntax is that you do not use parentheses when you provide arguments to
a Subroutine unless you preface it with the call command. You do use them
with a function if the function is returning a value. You don't use them
with a function if you are not using the returned value.

In help, all procedures are shown with the arguments in parentheses, but
this is not intended to say that you need to use parentheses - it is just a
typographical convention they are using.
 
M

Mark Worthington

Tom,

A voice of understanding in the darkness!

Thanks for your help,

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top