Check for / enable references from vba code

Bogzla

Registered User.
Local time
Today, 22:56
Joined
May 30, 2006
Messages
55
So I am using an excel sheet to transfer small amounts of data to a backend access database using ADODB - and to do this we need to set a reference to 'Microsoft ActiveX Data Objects x.x Library'. I typically try and use the most recent version but some of the machines here are somewhat older and may only have 2.0 / 2.1

so I was wandering if anybody knows a trick to check if certain references are available and enable the appropriate one (basically I want to run a sub from workbook_open to check if 2.8 is present, if so enable it, if not check for 2.7 and so on...)

any pointers would be gladly appreciated!

Bogzla
 
I suspect that the version of ADO would be related to version of Excel? If so, then perhaps this would work - or you could modify to be more specific.

Code:
Private Sub Workbook_Open() 
     
     'Notify what version is installed
    If Application.Version = 7 Then 
        MsgBox "You have Office '95 installed" 
    ElseIf Application.Version = 8 Then 
        MsgBox "You have Office '97 installed" 
    ElseIf Application.Version = 9 Then 
        MsgBox "You have Office 2000 installed" 
    ElseIf Application.Version = 10 Then 
        MsgBox "You have Office 2002 installed" 
    ElseIf Application.Version = 11 Then 
        MsgBox "You have Office 2003 installed" 
    ElseIf Application.Version > 11 Then 
        MsgBox "You have Office version " & Application.Version & " installed" 
    End If 
     
End Sub
________
K ENGINE
 
Last edited:

Users who are viewing this thread

Back
Top Bottom