Password to disable a userform for being run


Posted by Serge on May 16, 2001 3:26 PM

Hi!

I am trying to find a way which solves my problem:

I have designed a userform (in VBA for Excel), and i want to restrict the access to the form to only those persons who know the password. in addition, i want to offer the possibility of changing the password, but that is not the major problem. i want to find a way to store the password without that anyone can see it.

So, could you help me, please?

Posted by Dave Hawley on May 16, 2001 9:01 PM

Hi Serge

Create another UserForm and put 1 Textbox and one "Cancel" button and one "Ok" button.

Set the "PasswordChar" Property of the TextBox to "*"

Use this code for the "Cancel" button:

Private Sub CommandButton1_Click()
Unload Me
End Sub


Use this code for the "Ok" button.

Private Sub CommandButton2_Click()

If TextBox1 <> "secret" Then
MsgBox "Incorrect Password", vbCritical, _
"OzGrid Business Applications"
Exit Sub
End If

Run "MyMacro"

End Sub

Dave


OzGrid Business Applications

Posted by Richie Turner on May 17, 2001 2:36 AM

Dave

I've had this dilemma and in the past have gone about it in the way you have described, but the password itself ("secret") appears in the code. Is there a way if setting up a password so that it doesn't appear in the VBA code?

cheers

Richie


Posted by Anon on May 17, 2001 4:08 AM

Password protect the code module.

I've had this dilemma and in the past have gone about it in the way you have described, but the password itself ("secret") appears in the code. Is there a way if setting up a password so that it doesn't appear in the VBA code? cheers Richie

: Hi Serge : Create another UserForm and put 1 Textbox and one "Cancel" button and one "Ok" button. : Set the "PasswordChar" Property of the TextBox to "*" : Use this code for the "Cancel" button

Posted by Dave Hawley on May 17, 2001 4:46 AM

: Dave : I've had this dilemma and in the past have gone about it in the way you have described, but the password itself ("secret") appears in the code. Is there a way if setting up a password so that it doesn't appear in the VBA code? : cheers : Richie :

As annon has said Password protect the Project. Tools>VBA ProjectProperties-Protection.


...Or put the password in a cell on a Sheet which is xlveryhidden and refer to it. But the Password way is the best option.

Dave

OzGrid Business Applications



Posted by Serge on May 18, 2001 3:42 AM

ok, thank you very much. my problem is solved