Solved

Excel: Masking password in VBA

Posted on 2011-02-24
6
561 Views
Last Modified: 2012-05-11
Experts:

I am looking to add a masking over the password that a person is typing in the input box.  Currently, my code shows the code..  Any ideas on where to look?
0
Comment
Question by:Maliki Hassani
6 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 34976650
Do you require a macro for your masking? If no, you may consider setting "PasswordChar" for the Textbox Properties.

To do this:

1) right click your input box, and click "Properties".
2) In the "Properties" window, you should see "PasswordChar". Just put a character there.
0
 
LVL 41

Expert Comment

by:dlmille
ID: 34977174
Here's a good tip I contributed to recently.  Several options, though I like mine the best :).  It might do the trick.

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26818311.html

dave
0
 
LVL 41

Accepted Solution

by:
dlmille earned 500 total points
ID: 34977191
I put the tip in an xlsm worksheet for you.  Click the button to prompt for password.

Apparently Daniel Klann should be credited with the actual masking code.  Here's one citation http://www.ozgrid.com/forum/showthread.php?t=72794&page=1

Note in this post:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26818311.html

  I suggest having an addin that is separate from the application, that can be protected, for password validation.  You may/may not need that level of protection but advise if you do and I'll assist.

Also, its pretty easy to break password protection, with all the software out there to support that.


Dave
Password-r1.xlsm
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 45

Expert Comment

by:patrickab
ID: 34978371
LANCE_S_P,

Try the attached file - code below.

If in the Userform you select the TextBox and look at its Properties you will see that the Password character has been set to *. That means that whenever you press a key only an asterix will be shown in the TextBox. When you press the 'Use password' button it checks whether you have entered the correct password. If the password is correct the Userform will be hidden and unloaded.

In practice you of course need to lock the VBA project so that people cannot just read the VBA code to find out what the password is.

Patrick
Private Sub CommandButton1_Click()
If LCase(Me.TextBox1.Text) = "qwerty" Then
    MsgBox "Password was correct"
    Me.Hide
    Unload Me
Else
    MsgBox "Password was incorrect"
End If
End Sub

Open in new window

password-masking-01.xls
0
 

Author Closing Comment

by:Maliki Hassani
ID: 34978521
This was what I was looking for. Hackers are out there, this works best in vba..  Thanks
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34978534
LANCE_S_P,

>Hackers are out there, this works best in vba..

My solution only works in VBA!

Patrick
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now