I have a button in Excel that I want to password protect. I have the code to protect it but what is the code to show "*" instead of the actual password. Help.
Presumably you want to enter the password in a text box ... not on a button. If so, in design view, right click on the text box, select "Code View" and create a sub with the following
Code:
Private Sub TextBox1_GotFocus()
TextBox1.PasswordChar = "*"
End Sub
Actually what I have is control button that runs a macro in Excel when it is clicked. I want to have a text box pop up that asks for a password before the code is run. I have the following code in right now but when I type the password it shows the password.
mPass = InputBox("Please enter password to run macro"
If mPass <> "password" Then
MsgBox "Incorrect password"
Exit Sub
Else
Tell you the truth, I don't have a clue how to do this in an input box, but you could call a modal dialog with a text box whose "Password Char" in properties in set to * (or any other character). You could also hide a text box and label on your exsting for and when your magic button is clicked, make them both visible and set focus to the password text box.
If Excel "InputBox" is the VBS usual "InputBox" you have not a way to do it without resorting to FindWindow hackings and multithreading programming (what are not worth the work).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.