ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   call external macro (https://www.excelbanter.com/excel-programming/352799-call-external-macro.html)

gm139[_4_]

call external macro
 

Does anybody know the syntax to execute
a function stored in a .XLA file.

I have tried with

[projectname].[module].functionname

but i get an error.

Thanks


--
gm139
------------------------------------------------------------------------
gm139's Profile: http://www.excelforum.com/member.php...o&userid=26951
View this thread: http://www.excelforum.com/showthread...hreadid=510211


Dave Peterson

call external macro
 
This was posted by Rob Bovey:

Application.Run "'YourAdd-in.xla'!YourSubName", Arg1, Arg2, ....

Just for completeness, if the routine is a function and you want to capture
the return value, you write it as

x = Application.Run("'YourAdd-in.xla'!YourSubName", Arg1, Arg2)

========
Another alternative would be to add a reference to your workbook that points at
your addin.

Give your addin a nice unique project name (not VBAProject) and then with your
other workbook's project active:

Tools|references|
click on that addin's project.

Then you can use your functions/subs in the addin just like they were part of
that same project.

gm139 wrote:

Does anybody know the syntax to execute
a function stored in a .XLA file.

I have tried with

[projectname].[module].functionname

but i get an error.

Thanks

--
gm139
------------------------------------------------------------------------
gm139's Profile: http://www.excelforum.com/member.php...o&userid=26951
View this thread: http://www.excelforum.com/showthread...hreadid=510211


--

Dave Peterson

gm139[_5_]

call external macro
 

I have tried your second suggestion, that is exactly what I would like
to do.

In my .xla add-in I have a subroutine called "Import".

When I try to run it from my workbook I get an error.

What is the syntax to be used to call a sub or function in an xla
file?

I have tried several different syntax but no one works.


--
gm139
------------------------------------------------------------------------
gm139's Profile: http://www.excelforum.com/member.php...o&userid=26951
View this thread: http://www.excelforum.com/showthread...hreadid=510211


Dave Peterson

call external macro
 
What did you try?

I would have guessed that:
x = Application.Run("'YourAdd-in.xla'!YourSubName", Arg1, Arg2)

would have worked fine.

gm139 wrote:

I have tried your second suggestion, that is exactly what I would like
to do.

In my .xla add-in I have a subroutine called "Import".

When I try to run it from my workbook I get an error.

What is the syntax to be used to call a sub or function in an xla
file?

I have tried several different syntax but no one works.

--
gm139
------------------------------------------------------------------------
gm139's Profile: http://www.excelforum.com/member.php...o&userid=26951
View this thread: http://www.excelforum.com/showthread...hreadid=510211


--

Dave Peterson

sylvain

call external macro
 
Hello Dave,

Thanks a lot because I was looking for a similar problem,
something like :
x = Application.Run("'D:\...\YourAdd-in.xla'!YourSubName", Arg1, Arg2)

and it wasn't working while I didn't use the "'" character...

Best regards, Sylvain


Dave Peterson a écrit :
What did you try?

I would have guessed that:
x = Application.Run("'YourAdd-in.xla'!YourSubName", Arg1, Arg2)

would have worked fine.

gm139 wrote:

I have tried your second suggestion, that is exactly what I would like
to do.

In my .xla add-in I have a subroutine called "Import".

When I try to run it from my workbook I get an error.

What is the syntax to be used to call a sub or function in an xla
file?

I have tried several different syntax but no one works.

--
gm139
------------------------------------------------------------------------
gm139's Profile: http://www.excelforum.com/member.php...o&userid=26951
View this thread: http://www.excelforum.com/showthread...hreadid=510211




Dave Peterson

call external macro
 
Remember that the other workbook has to be open--so drop the drive/path stuff.

sylvain wrote:

Hello Dave,

Thanks a lot because I was looking for a similar problem,
something like :
x = Application.Run("'D:\...\YourAdd-in.xla'!YourSubName", Arg1, Arg2)

and it wasn't working while I didn't use the "'" character...

Best regards, Sylvain

Dave Peterson a écrit :
What did you try?

I would have guessed that:
x = Application.Run("'YourAdd-in.xla'!YourSubName", Arg1, Arg2)

would have worked fine.

gm139 wrote:

I have tried your second suggestion, that is exactly what I would like
to do.

In my .xla add-in I have a subroutine called "Import".

When I try to run it from my workbook I get an error.

What is the syntax to be used to call a sub or function in an xla
file?

I have tried several different syntax but no one works.

--
gm139
------------------------------------------------------------------------
gm139's Profile: http://www.excelforum.com/member.php...o&userid=26951
View this thread: http://www.excelforum.com/showthread...hreadid=510211




--

Dave Peterson


All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com