Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Programmatically setting references in VBA

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #2
    MrExcel MVP Damon Ostrander's Avatar
    Join Date
    Feb 2002
    Location
    Denver, Colorado USA
    Posts
    4,239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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
    LinkedIn Profile http://www.linkedin.com/pub/damon-ostrander/7/79/a93
    AllExperts Profile http://www.allexperts.com/ep/1059-30...-Ostrander.htm

  3. #3
    New Member
    Join Date
    May 2006
    Location
    Sydney
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default 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

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •