Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to password protect an application
I have an application for which I want the user to use a password
before being able to use it. I want the user to be able to make up to three tries before terminating the application. If I use an InputBox to prompt for the password the user can click Cancel or Close and can get to the application worksheet without using any password. If I use a UserForm with a TextBox to enter the password how can I display the password TextBox up to three times without unloading and reloading the UserForm. If wrong password the user would get a critical MsgBox which when clicked OK would get, up to three times, immediately back to the TextBox to re-enter the password. Thanks for any help, Nathan |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to password protect an application
Hi Nathan
One way among several. Userform1 code (with a Textbox1 for entry and a CommandButton1 saying "OK" + default=true): Option Explicit Public Pwd As String Private Sub CommandButton1_Click() Pwd = TextBox1.Text Me.Hide End Sub In a standard module: Option Explicit Sub Auto_open() Dim Count As Long Dim GoodGuy As Boolean GoodGuy = False For Count = 1 To 3 With UserForm1 Select Case Count Case 1 .Caption = _ "Password please" Case 2 .Caption = _ "Try again please" Case 3 .Caption = _ "Last chance:" End Select .Show If .Pwd = _ "Nathan Rules" Then GoodGuy = True Exit For End If End With Next Unload UserForm1 If GoodGuy = True Then Sheets(1).Visible = True MsgBox "Yo da man" Else Sheets(1).Visible = xlVeryHidden ThisWorkbook.Save ThisWorkbook.Close End If End Sub Please don't MsgBox at wrong entries, thay have to be OK'ed away and are all over extremely annoying. Use a label on the form, it's caption, color or whatever. Anything but msgboxes. -- HTH. Best wishes Harald Followup to newsgroup only please. "Nathan Gutman" wrote in message ... I have an application for which I want the user to use a password before being able to use it. I want the user to be able to make up to three tries before terminating the application. If I use an InputBox to prompt for the password the user can click Cancel or Close and can get to the application worksheet without using any password. If I use a UserForm with a TextBox to enter the password how can I display the password TextBox up to three times without unloading and reloading the UserForm. If wrong password the user would get a critical MsgBox which when clicked OK would get, up to three times, immediately back to the TextBox to re-enter the password. Thanks for any help, Nathan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to password protect an application
John Wilson offers one suggestion in this thread.
http://www.google.com/groups?hl=en&l...ecc1a98&rnum=1 HTH Paul -------------------------------------------------------------------------------------------------------------- Be advised to back up your WorkBook before attempting to make changes. -------------------------------------------------------------------------------------------------------------- I have an application for which I want the user to use a password before being able to use it. I want the user to be able to make up to three tries before terminating the application. If I use an InputBox to prompt for the password the user can click Cancel or Close and can get to the application worksheet without using any password. If I use a UserForm with a TextBox to enter the password how can I display the password TextBox up to three times without unloading and reloading the UserForm. If wrong password the user would get a critical MsgBox which when clicked OK would get, up to three times, immediately back to the TextBox to re-enter the password. Thanks for any help, Nathan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Password Protect | Excel Worksheet Functions | |||
VBA password protect | New Users to Excel | |||
Password Protect | Excel Discussion (Misc queries) | |||
How do I protect Visual Basic for Application Code | New Users to Excel | |||
How do I protect my hidden Excel.Application object from unwanted user interaction. | Excel Programming |