TheJonWithNoH
New Member
- Joined
- Sep 8, 2017
- Messages
- 30
Hello,
I have several Excel workbooks that use a code that pulls DSN names from the registry into a userform and supplies DSN, username & password to access an ODBC connection. I just got a new laptop with Windows 10 and it's not working. I first got a "Runtime 13 Mismatch" error but I was able to drill down and find that the code is not finding the DSN names (arrValueNames). Everything works fine on all of our other machines which are running Windows 7, but I cant seem to figure out what is going on with this new Windows 10 machine.
Here's part of the code that I am using on the Userform:
I have several Excel workbooks that use a code that pulls DSN names from the registry into a userform and supplies DSN, username & password to access an ODBC connection. I just got a new laptop with Windows 10 and it's not working. I first got a "Runtime 13 Mismatch" error but I was able to drill down and find that the code is not finding the DSN names (arrValueNames). Everything works fine on all of our other machines which are running Windows 7, but I cant seem to figure out what is going on with this new Windows 10 machine.
Here's part of the code that I am using on the Userform:
Code:
Private Sub UserForm1_Initialize()
Dim i As Double
Application.Cursor = xlDefault
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC DATA SOURCES"
objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
For i = 0 To UBound(arrValueNames)
strValueName = arrValueNames(i)
objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
Next
For Each strValueName In arrValueNames
Me.ComboBox1.AddItem strValueName
Next strValueName
End Sub