Fetching the reference description

I've always been irritated at how you can't get at the user friendly reference description as displayed in the Access VBA References screen.

  VBAReferences

When you look at the properties of the reference object you can't see the user friendly name you see on the above screen. 

Sub DebugPrintReferences()

Dim ref As Reference
    For Each ref In Access.References
        Debug.Print ref.Name & " " & _
            IIf(ref.IsBroken, "Broken", "") & _
            ref.Major & "." & ref.Minor & " " & _
            ref.FullPath
    Next ref

End Sub

The above code will only show you:

VBA 4.0 C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL
Access 9.0 C:\Program Files\Microsoft Office 2003\OFFICE11\msacc.olb
DAO 5.0 C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll
stdole 2.0 C:\WINDOWS\system32\stdole2.tlb

Not very user friendly when you're trying to post to a newsgroup telling someone what needs to be removed or added.

However fellow Access MVP Thomas Möller suggested adding a reference to Microsoft Visual Basic for Applications Extensibility 5.3 and the following code. (Slightly modified)

Sub DebugPrintReferencesIDE()

' For the refIDE to work a reference must be set to Microsoft Visual Basic for
'       Applications Extensibility 5.3
Dim refIDE As VBIDE.Reference

    For Each refIDE In Access.Application.VBE.ActiveVBProject.References
        Debug.Print refIDE.Description & " " & _
            IIf(refIDE.IsBroken, "Broken", "") & vbCrLf & _
            "     " & refIDE.Name & " " & refIDE.Major & "." & refIDE.Minor & " " & refIDE.FullPath
    Next refIDE

End Sub

which gives you the following:

Visual Basic For Applications
     VBA 4.0 C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL
Microsoft Access 11.0 Object Library
     Access 9.0 C:\Program Files\Microsoft Office 2003\OFFICE11\msacc.olb
Microsoft DAO 3.6 Object Library
     DAO 5.0 C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll
OLE Automation
     stdole 2.0 C:\WINDOWS\system32\stdole2.tlb
Microsoft Visual Basic for Applications Extensibility 5.3
     VBIDE 5.3 C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB

Published Sun, Feb 24 2008 19:17 by Tony
Filed under: , ,

Comments

# re: Fetching the reference description

This is really very usefull. i don´t know how often I already was frustrated by the default reference description. Your description  is instaed really good. Do you have any idea how to implement it in vb6. As far as I know there is no vbe object after compilation, so it´s not useable.

I´d like to have a list of all refences in the about dialog of the compiled application. Thanks for every hint, best regards, alexander.muehlbauer@gesis.org

Wednesday, February 27, 2008 6:07 AM by Alexander Muehlbauer

# re: Fetching the reference description

VB6? I have no idea.  I'd suggest asking in some VB6 newsgroups.

Or try spendingt the time going through the results at groups.google.com, Advanced Search, Group = hiermicrosoft.public.vb.* and appropriate keywords in words boxes.

Wednesday, February 27, 2008 2:28 PM by Tony

# re: Fetching the reference description

very handy code; make convenient work of automating references...thank you!

Tuesday, March 18, 2008 3:26 PM by vb

# re: Fetching the reference description

Very handy....thank you. I sometimes get frustrated that Access does not always update references between versions...for example a calendar control or Outlook reference.

Saturday, May 03, 2008 2:38 PM by Paul

# re: Fetching the reference description

Paul, I'd suggest using a calendar form or the API call which is exactly what the calendar control uses.

See the Calendar Tips page at my website

www.granite.ab.ca/.../calendars.htm

As far as the Outlook, or Excel, or Word reference problem using Late Binding.

Late binding means you can safely remove the reference and only have an error when the app executes lines of code in question.  Rather than erroring out while starting up the app and not allowing the users in the app at all.  Or when hitting a mid, left or trim function call.  

This also is very useful when you don't know  version of the external application will reside on the target system.  Or if your organization is in the middle of moving from one version to another.

For more information including additional text and some detailed links see the "Late Binding in Microsoft Access" page at www.granite.ab.ca/.../latebinding.htm

Saturday, May 03, 2008 3:58 PM by Tony

# Another method of getting the lengthy reference description

In my blog posting Fetching the reference description I was told that adding a reference to Microsoft

Friday, July 17, 2009 11:39 PM by Tony's Microsoft Access Blog

# re: Fetching the reference description

It is important to realize the an Access.Reference and VBEIDE.Reference are two different and incompatible object types.  Granted they may get there information from the same physical thing memory, but the concept is not any different than an ADODB.Recordset and a DAO.Recordset.

Sunday, July 19, 2009 10:33 AM by Brent Spaulding

Leave a Comment

(required) 
(required) 
(optional)
(required)