You know how when you type your password in most programs it’s masked? That’s good. You don’t want your co-workers peering over your shoulder and messing with your eBay account. Well, you can do the same thing in VBA. Specifically, using Textboxes on Userforms. The Textbox control has a PasswordChar property which you can set to any character you’d want, like *.
Now when the user types in the Textbox, the text is masked.
Unfortunately, the InputBox method and function don’t have this property. You have to make a Userform to use it.
10 thoughts on “Password Characters”
I like this solution:
just because it shows that you *can* do it with an InputBox… of course, using the Userform may be easier to implement !
Good one, Juan. I remembered that I had seen that before when I went there because he uses my initials in his function.
Keep in mind that in order to use something like this, the password needs to be stored somewhere in a VBA module. And we all know that the protection for VBA modules is very weak. In other words, using a password provides absolutely no guarantee that you will keep out the people you want to keep out.
What would you recommend for protection to keep people out?
Or, letting them view, but not change the information?
Stac, for 98% of users’ applications, simply protecting an Excel file with a password (and possibly hiding and protecting the VBA code) would be sufficient. The passwords can be cracked with some 3rd party software applications, but if you need true unbreakable protection, then perhaps straight Excel would not be the way to go.
Thanks for the confirmation. It is as I suspected. My company is reeling from some implications of Sarbanes-Oxley and our usage of Excel sheets.
Not sure how we are going to proceed, but considering the number of Excel sites I’ve checked this fact on, our practices will have to change.
Thanks for the confirmation. It is as I suspected. My company is reeling from some implications of Sarbaines-Oxley and our usage of Excel sheets.
Not sure we are going to proceed, but considering the number of Excel sites I’ve checked this fact on, our practices will have to change.
thanks for the explanation. it’s so usefull….
I typically keep passwords saved in a Named Range (not on a sheet). If this range is hidden, would it change your opinion?
A hidden name is much easier to unhide than a protected VB project is to unprotect.
For Each nm In ActiveWorkbook.Names
nm.Visible = True
Now you can see it in the Define Names dialog. To unprotect a VB project which has an unknown password, you have to hack into the file using a hex editor.
Posting code? Use <pre> tags for VBA and <code> tags for inline.