Excel / Visual Basic Userform & Reading from registry on Windows 10

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:

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
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top