Addins - calling functions

  • Thread starter Thread starter Steven Revell
  • Start date Start date
S

Steven Revell

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
 
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
 
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
 
Back
Top