PDA

View Full Version : Including or Referencing a Module from other Workbooks



deyken
10-07-2009, 10:36 PM
Good Day All!

I have had a lot of good luck with you experts, so I am going to take another shot here:

I can't seem to "reference..." an extra Module I wrote. This particular module is indeed accessible through other modules within the same active worksheet, through the object.method approach. I simply wrote a group of functions which I found myself rewriting time and time again. Now I have them available in a centralised location (like an #include file). How do I easily reference this module?

I was also interested in finding out whether or not I could develop a DLL in Delphi (my strong suit IDE) which I could then somehow include/reference from several separate VBA Projects. Is calling exterrnal DLL functions possible in VBA?

Thanks!

JP2112
10-09-2009, 10:10 AM
I believe the syntax is

Workbookname!Module.Function

With 'Module' being optional if the function name is unique.

Note that if you set a reference to the workbook (using Tools > References in the VB IDE) you don't need to qualify the function name with the Workbook name.

Also, you could put those common functions into a separate workbook, save the workbook as an add-in and install it, and you could use them that way (also without qualifying them with the workbook name).

As for your question about DLLs and Delphi, I'm afraid that's beyond me.

deyken
10-11-2009, 10:21 PM
Hi JP2112,

Thanks a lot. Could I use the "Save As..." function in Excel to save a workbook as an add-in? How do I go about installing it?

Look forward to your reply!

JP2112
10-12-2009, 02:51 PM
For information on creating Excel add-ins, see http://www.fontstuff.com/vba/vbatut03.htm

To install an add-in, see http://www.bettersolutions.com/excel/ECA723/LD023821888.htm

deyken
10-12-2009, 09:59 PM
Thanx, bud!