Addins - calling functions

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
 
K

Kent Prokopy

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
 
T

Tom Ogilvy

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
 

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