Programmatically setting references in VBA

karraj

Board Regular
Joined
Mar 5, 2002
Messages
76
Is it possible to programatically set references in VBA?
Trying to record a macro does not work for adding references in VBA.
Any help will be appreciated..
K
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi Karraj,

First, you must have the reference for Microsoft Visual Basic for Applications Extensibility set. This loads the VBIDE library. Within this library there is a References collection. To add references to Excel, use the AddFromGuid (if you know the reference's programmatic identifier) or the AddFromFile (if you know the references .olb filename) methods to add the references. To remove the references use the Remove method of the References collection. The help files for these methods are in the Extensibility library I mentioned above, so once you have it loaded you can look at the examples in the help files.
 
Upvote 0
Problems with References Collection

Hi Damon,

I have attempted to use the references collection ... with little success!

I wanted to reference an Outlook Object library, depending on the version of Outlook that was installed on the user's machine. I seached their harddrive for the appropriate library, and then attempted to "tick" that reference using the refs collection. This particular library was already in the reference list (unchecked), and would not allow me to add another ref with the same name!!!

Do you know of a way to check items (programatically) within the "references Dialog?

cheers,
DW
 
Upvote 0

Forum statistics

Threads
1,214,899
Messages
6,122,155
Members
449,068
Latest member
shiz11713

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top