Can anyone see why this would fail?

Sven62

Active Member
Joined
Feb 21, 2012
Messages
485
The following code worked fine until some of the computers were upgraded to Windows 10 from Windows 7.

The upgraded computers work fine except for this code. The textbox appears and the correct password is entered... then they get "The password was wrong, try again." WHY!!!!!???? I do not understand!! Someone? Anyone?

Is there a better way to write this? Obviously the goal is a password textbox that will accept the correct password like it used to do. TIA!

Code:
[COLOR=#333333]Private Sub UserForm_Activate() With UserForm13[/COLOR]   .Top = Application.Top + 275
   .Left = Application.Left + 200
 End With
End Sub


Private Sub CommandButton1_Click()


Dim strPass As String


strPass = "nakosi"


If TextBox1.Value = strPass Then
    Call UnprotectAllSheets
    Unload Me
Else
    If MsgBox("The password was wrong, try again", vbYesNo) = vbNo Then
        Unload Me
    Else
        TextBox1.Value = ""
        TextBox1.SetFocus
    End If
End If [COLOR=#333333]End Sub[/COLOR]
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
The only thing I can think of is either file corruption, or for some reason garbage data getting in.

First, I'd suggest changing the code slightly.

Code:
Private Sub UserForm_Activate()

    With UserForm13
        .Top = Application.Top + 275
        .Left = Application.Left + 200
    End With
End Sub


Private Sub CommandButton1_Click()

Dim strPass As String
Dim strTextbox As String


    strPass = "nakosi"

    strTextbox = Trim(LCase(TextBox1.Value))

    If strTextbox = strPass Then
        Call UnprotectAllSheets
        Unload Me
    Else
        If MsgBox("The password was wrong, try again", vbYesNo) = vbNo Then
            Unload Me
        Else
            TextBox1.Value = ""
            TextBox1.SetFocus
        End If
    End If
End Sub

Adding the trim and lowercase function might keep out erroneous data

Failing that, there may have been a glitch while installing Win 10.

If that is the case, paste the code from the form into notepad. Delete the form and re-create it. Then paste the code from notepad back into the code section of the re-created form.

I've run across this in the past myself.

Good luck, and let me know if this works.
 
Upvote 0
Thank you for responding. We have not tried your method yet because...

We discovered the Win 10 Ent. boxes are reading the "******" characters in the textbox as actually "******" instead of reading the underlying password.
When we changed the password to nothing "" then everything worked fine.
When we added the password back in but removed the Password Char * from the textbox properties, so you could see the password as you typed it, then everything worked fine.
But it simply would not read the password if it was being masked by a Password Char setting.

That's crazy.

Given all that, I doubt the Trim idea will bear fruit. We did almost recreate the form like you suggested, but then discovered the read error. Still may try it.
 
Last edited:
Upvote 0
You may also want to try compiling the project again. It might help. Excel can get corrupted very easily
 
Upvote 0
Just in case :
Code:
[COLOR=#333333]If UCase(strTextbox)= UCase(strPass) Then[/COLOR]
 
Last edited:
Upvote 0
Just in case :
Code:
[COLOR=#333333]If UCase(strTextbox)= UCase(strPass) Then[/COLOR]

Thanks, but we have been very careful about case. And the fact that the workbook functioned correctly when we removed Password Char masking is telling us the whole story. And it's not just this one computer doing it - it's every single one that was upgraded to Win 10 Enterprise. And all the Win 7 computers can still run the workbook just fine. Also, my home Win 10 runs it fine.
 
Upvote 0
Have you tried reinstalling office on these machines?

We've had some of the most bizarre issues resolved by doing that.
 
Upvote 0
Where is the password masking coming from? I haven't done that in ages - is it something in the userform textbox properties?
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,215
Members
452,618
Latest member
Tam84

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