Check for the Newest Available Library

C

crferguson

Hello all! I was wondering if there was a way to programmatically get
a list of available reference libraries on the running computer and
then determine which library of a certain type is the newest, such as
the newest version of ADO?

Thank you!

Cory
 
J

JP

You would need to know the filenames and the current version of each
object library.

You could iterate through the collection like this:

For i = 1 To ThisWorkbook.VBProject.References.Count
MsgBox "Name: " & _
ThisWorkbook.VBProject.References.item(i).Name & vbCr & _
"Path: " & _
ThisWorkbook.VBProject.References.item(i).FullPath
Next i

You could use code like this to test out if a reference is available:

On Error Resume Next
' add a reference to MS Word 2003
ThisWorkbook.VBProject.References.AddFromFile _
("C:\Program Files\Microsoft Office\Office11\MSWORD.OLB")
On Error Goto 0
If Err = 0 Then
' your code continues
Else
MsgBox "MS Word 2003 not available on this computer"
End If

Each ADO library has a different filename so you could use the first
code to see if it is already installed. Then you can use the second
code to add it, if it isn't installed.

This is air code so test it first.

HTH,
JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top