Entering Passwords

M

megan

I am using the following code for a user to password protect opening a
worksheet.

Private Sub Worksheet_Activate()

Dim strPassword As String
On Error Resume Next
Const Password = "mmmmmm"

Me.Protect Password:=Password
Me.Columns.Hidden = True

strPassword = InputBox("Enter password to view this sheet")

If strPassword = "" Then
Me.Previous.Select
Exit Sub
ElseIf strPassword <> Password Then
MsgBox "Password Incorrect", , "Wrong password"
Me.Previous.Select
Exit Sub
Else
Me.Unprotect Password:=Password
Me.Columns.Hidden = False
End If

On Error GoTo 0
End Sub

Everything works fine except when they type in their password the actual
password shows. Can anyone please help me add a piece of code so that when
they type only asterisks appear and not the password if possible. Thanks
 
J

JE McGimpsey

megan said:
Everything works fine except when they type in their password the actual
password shows. Can anyone please help me add a piece of code so that when
they type only asterisks appear and not the password if possible. Thanks

Input boxes will always show the typed text.

To hide input text, create a Userform with a textbox. Set the textbox's
PasswordChar property to an asterisk.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top