Passing a Reference in VBA

B

Bill

Hello,
I want to pass a argument to a macro to run. I have tried
application.run but can only pass numerical values. I need to pass a
string. I have been told you can add a reference in VBA to the
appropriate .xla file and was able to invoke public methods to pass the
arguments of the appropriate type. He said go to tools, references and
then add a reference.

Does anyone know how to do this?

Thanks,

Bill

*** Sent via Developersdex http://www.developersdex.com ***
 
T

Tom Ogilvy

passing a string with application.run should be no problem

application.Run "MyXLA.xla!Mymacro", "abc"

as an example.

Is there something special - is the string longer than 255 characters?
 
C

Chip Pearson

You can certainly pass string arguments using Application.Run.


Sub AAA(S As String)
Debug.Print S
End Sub

Sub BBB()
Application.Run "AAA", "abcd"
End Sub

To call methods directly from your XLA as if they were built-in
VBA functions, first open the XLA and go to the Tools menu and
choose VBA Project Properties. Change the name from VBA project
to something more meaningful. Then, choose References from the
Tools menu and put a check next to the name you gave your XLA.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

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