Importing libraries explicitly in macro code

S

shivboy

I am working on a project which uses the following object libraries:

Microsoft DAO 3.6 Object Library
Microsoft ADO Ext. 2.8 for DDL and Security
Microsoft Access 10.0 Object Library
Microsoft ActiveX Data Objects 2.0 Library

How can I explicitly inherit these libraries in my macro code so tha
no error is thrown due to non-inheritance of the libraries in user'
machine.

Furthermore, is there a location where I can find the complet
reference list of these libraries?

Please help.

Peace,

Shivbo
 
J

John.Greenan

if you set a workbook reference then this should remain in you addin after
you distribute it. What is the problem you are encountering - that the user
does not have the dlls on his/her PC? There's no way to statically link in
excel vba.

You can try and use Microsoft Visual Basic for Applications Extensibility
5.3 - typically installed in "C:\Program Files\Common Files\Microsoft
Shared\VBA\VBA6\VBE6EXT.OLB" and then use

Dim oReference As VBIDE.Reference
and

ThisWorkbook.VBProject.References.AddFromFile
or
ThisWorkbook.VBProject.References.AddFromGuid

to add the references at run time. It's quite tricky, as you will have to
identify the GUID or file names and then work out how to handle the missing
reference.
 
S

shivboy

Hi John,

The reason I raised this question was because I am making a macro in
Excel VBA which creates tables in Access, then provides user form to
enter data into the tables and finally retrieve data from the tables to
generate reports. Now, to do all this, I have had to use various library
references while making the code work. Since I had to manually go to
Tools > References to import the libraries, I am sure that the same
issue would lie with every user who would run the macro on his/her PC.
In that case, I cannot expect the user to first import all the files
manually and then start using the macro. It is for that purpose that I
wanted to inherit / import the required libraries into the code so that
wherever the code is run it works fine.

I am sure there must be a way to import these libraries so as to ensure
that the macro works fine everytime it is run.

Peace,

Shivboy
 
J

John.Greenan

Have you written this code? Have you distributed it? How are you writing
the code?
What actual problem are you encountering, rather than what problems you
think you may encounter. I'm happy to help, but what is the actual problem?
References are saved in addins...
 

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