Set library reference from VBA code

G

Guest

Currently, to select/deselect a library reference, I open the Tools /
References menu option and click on/off the library that I need.

I am wondering if there is a way to select/deselect a library using VBA code
(i.e. without having to manually use the point and click method).

Any help is appreciated.

Thanks in advance.
Kevin
 
D

Donald Fisher

I understand how to add via the AddFromFile method but how from th
AddFromGUID method?
 
D

Douglas J. Steele

Each reference has a GUID associated with it, as well as a Major and Minor
property. You can store those properties, and then use then to add the
reference. For example, I've got a project that's using the Microsoft
Internet Controls.

I can add that reference programmatically using either

References.AddFromFile "C:\Windows\System32\shdocvw.dll"

or

References.AddFromGUID "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 1, 1

However, based on questions you've posted to other newsgroups, I'd recommend
you use Late Binding, rather than worrying about trying to add or remove
references based on what's installed on the user's workstation.
 

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