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
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
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
: 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
ok, thank you very much. my problem is solved