Getting reference information

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
I am stumbling on how to retrieve the information on all references that are set in a vbproject using Excel 2010. So that I can test for the references a certain project requires and set them via code if necessary. I have tried various ways, all are breaking. MSDN wasn't that helpful.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Code:
Sub AllRefs()

    Dim ref As Object
    For Each ref In ThisWorkbook.VBProject.References
        MsgBox ref.Description
    Next

End Sub
 
Upvote 0
For this to work check checkbox:
File -> Options -> Trust Center -> Trust Center Settings -> Macro Settings -> Trust access to the VBA project object model.

Code:
Sub AllRefs()
    
    ' Tools -> References -> Microsoft Visual Basic for Applications Extensibility 5.3
    
    Dim ref As Reference
    
    For Each ref In ThisWorkbook.VBProject.References
        MsgBox ref.Description
    Next

End Sub
 
Upvote 0
Andrew,

The reason I want to set them via code is because if you create the workbook in excel 2010 for example and someone runs it on excel 2007 then you get a reference error and the Outlook 2010 reference, for example, shows as MISSING in the references. So I want to test for version number and set them accordingly
 
Upvote 0
Can anyone point me as to where I can find the other methods under VBProject besides References? I don't see them in Object Browser or on MSDN
 
Upvote 0
Helpful, but I'm looking for a table of all the references GUID info
(for example) VBProject.References.AddFromGuid("{0002E157-0000-0000-C000-000000000046}", 0, 0)
so I can have a reference lookup for the app based on what version of Excel the person is running and then set the reference appropriately.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,875
Members
452,949
Latest member
Dupuhini

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