Reputation: 522
Is there any easy way to call ODBC Oracle Instant Client without specifying the driver name in VBA?
I have developed a VBA an application that is shared across multiple users. However, they all have a different Oracle Instant Client version installed (from 19.6 to 21.7). Am it make me hard to share across the team as I need to change the drive name on the script.
Is there any easy way so that I can call the ODBC connectivity without using the driver name?
Upvotes: 0
Views: 197
Reputation: 325
Below function will return the currently installed driver (in this case MariaDB, change to your desires). We use this to see if the minimum required version is installed but i guess you can use it to work with whatever version in installed without addressing it specifically.
Function ODBCVers() As String
Const HKEY_LOCAL_MACHINE = &H80000002
StrComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & StrComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
For i = 0 To UBound(arrValueNames)
If Left(arrValueNames(i), 12) = "MariaDB ODBC" Then
ODBCVers = CStr(arrValueNames(i))
ODBCVers = Replace(ODBCVers, "ANSI", "Unicode")
Exit For
End If
Next
End Function
Upvotes: 1