?
Solved

Excel: Masking password in VBA

Posted on 2011-02-24
6
Medium Priority
?
588 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 42

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 42

Accepted Solution

by:
dlmille earned 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

839 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