Solved

Excel: Masking password in VBA

Posted on 2011-02-24
6
562 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Input Macro 8 23
Excel - count records based name and based on null and not null 5 31
macro for each dropdown 15 44
Excel Formula 4 28
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

919 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

20 Experts available now in Live!

Get 1:1 Help Now