View Full Version : Check for / enable references from vba code


Bogzla
01-04-2007, 07:19 AM
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

shades
01-04-2007, 08:40 AM
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.


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