ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to call a macro in an XLA add-in (https://www.excelbanter.com/excel-discussion-misc-queries/17015-how-call-macro-xla-add.html)

Peter Laman

How to call a macro in an XLA add-in
 
Hello,

This is an XLA newbie question (for Excel 2000)!

I created an Excel addin (.xla type) with a macro in it and I
installed the add-in. Then I opened another workbook, activated my VBA
form and yes, there it was, my add-in.

But now I want to create a macro in the workbook that calls a macro
from the add-in (with parameters). How can I do that? My end goal of
this is to create an add-in as a subroutine and function library for
an extensive set of Excel sheets that need to be developed.

Thanks for any help!

Dave Peterson

This was just 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.

Peter Laman wrote:

Hello,

This is an XLA newbie question (for Excel 2000)!

I created an Excel addin (.xla type) with a macro in it and I
installed the add-in. Then I opened another workbook, activated my VBA
form and yes, there it was, my add-in.

But now I want to create a macro in the workbook that calls a macro
from the add-in (with parameters). How can I do that? My end goal of
this is to create an add-in as a subroutine and function library for
an extensive set of Excel sheets that need to be developed.

Thanks for any help!


--

Dave Peterson


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

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