ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Addins - calling functions (https://www.excelbanter.com/excel-programming/280024-addins-calling-functions.html)

Steven Revell

Addins - calling functions
 
Hi,

I have an addin which contains VBA code. I was wondering
how to call these functions from with the VBA of an open
workbook. e.g. to call my user defined save routine within
the xla.

Thanks for any help,

Steven

Kent Prokopy[_3_]

Addins - calling functions
 
Try the following:

Private xlApp As New Excel.Application

Public Sub Main()
xlApp.Workbooks.Open "C:\Book1.xla"
xlApp.Run "Book1.xla!MyModule"
xlApp.Quit
Set xlApp = Nothing
End Sub


"Steven Revell" wrote in message
...
Hi,

I have an addin which contains VBA code. I was wondering
how to call these functions from with the VBA of an open
workbook. e.g. to call my user defined save routine within
the xla.

Thanks for any help,

Steven




Tom Ogilvy

Addins - calling functions
 
You don't need to run a new instance of excel to run a function from an xla.
If it is loaded

Application.Run "Book1.xla!MyModule"

Should work fine.

If you set a reference to it (in the VBE, Tools=References), you can call
it just like the function is in the subject workbook.


MyModule


--
Regards,
Tom Ogilvy


"Kent Prokopy" wrote in message
...
Try the following:

Private xlApp As New Excel.Application

Public Sub Main()
xlApp.Workbooks.Open "C:\Book1.xla"
xlApp.Run "Book1.xla!MyModule"
xlApp.Quit
Set xlApp = Nothing
End Sub


"Steven Revell" wrote in message
...
Hi,

I have an addin which contains VBA code. I was wondering
how to call these functions from with the VBA of an open
workbook. e.g. to call my user defined save routine within
the xla.

Thanks for any help,

Steven







All times are GMT +1. The time now is 08:56 AM.

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