Calling procedures/functions in other VBAProjects

  • Thread starter Thread starter robbinma
  • Start date Start date
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
 
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()
 
Back
Top