![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 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 |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, Colorado USA
Posts: 4,014
|
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.
__________________
Keep Excelling. Damon VBAexpert Excel Consulting (My other life: http://damonostrander.com ) |
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2006
Location: Sydney
Posts: 2
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|