Calling procedures/functions in other VBAProjects

R

robbinma

Hi,

I have a function in one project that I am trying to call from another
without any success.
Going through the documentation it looks like I should be able to
define the function in my add in (tms_it.xla) and call it from a
function another project & module. E.g.

VBAProject (tms_it.xla) Module->General Utils->WorksheetExists
being called by
VBAProject (ins_test.xls) Module->utils->loadData

I'm not using "option private module" anywhere to prevent the functions
being used and I have prefixed the function with the keyword Public.

Any ideas on what is going on and how I can fix this please.
I really don't want to copy the worksheetExists function into the
ins_test.xls worksheet because then I can't share the code
efficiently.

Regards,

Mark
 
C

Chip Pearson

Mark,

First, open the project that contains the procedure you want to use. Go to
the Tools menu in VBA, choose Properties, and give the project some name
like TMSProj. Save the file. Then, open the project that will call the
procedure. Go to the Tools menu in VBA and choose References. In that
dialog, find your TMSProj in the list and put a check next to that entry.

You can then call functions in TMSProj directly, or by prefixing the library
name to the function. E.g.,

Result = WorksheetExists()
or
Result = TMSProj.WorksheetExists()
 

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