User form- protection and password.

  • Thread starter Thread starter TUNGANA KURMA RAJU
  • Start date Start date
T

TUNGANA KURMA RAJU

How to protect a userform (code + object) by assigning a password?
 
Hi Tungana,

===========
How to protect a userform (code + object) by assigning a
password?===========

Try password protecting the VBA project:

In the VBE,

Menus | Tools | VBAProject Properties | Protection |
Lock Project for viewing [x] |
Enter and confirm Password | OK
Save, close and re-open the file.
 
I follwed your instruction ,the user form is still opening after clicking the
Rectangle to which I assignined the user form code
 
Hi Tungana,

I misunderstood; I assumed that you wished
to prevent access to the Userform module.

Try assigning something like the following
code to your rectangle:

'==========>>
Sub Rectangle1_Click()
Dim Res As String
Const PWORD As String = "ABC" '<<==== CHANGE

Res = InputBox(Prompt:="Enter password")

If Res <> PWORD Then
MsgBox Prompt:="The password has not " _
& "been recognised!", _
Buttons:=vbCritical, _
Title:="Password"
Exit Sub
End If

'Your code to open theUserform, e.g.:
Userform1 , Show

End Sub
'<<==========



---
Regards.
Norman


TUNGANA KURMA RAJU said:
I follwed your instruction ,the user form is still opening after clicking
the
Rectangle to which I assignined the user form code

Norman Jones said:
Hi Tungana,

===========
How to protect a userform (code + object) by assigning a
password?===========

Try password protecting the VBA project:

In the VBE,

Menus | Tools | VBAProject Properties | Protection |
Lock Project for viewing [x] |
Enter and confirm Password | OK
Save, close and re-open the file.
 
Thank you,Norman Jones,Its working !!!

Norman Jones said:
Hi Tungana,

I misunderstood; I assumed that you wished
to prevent access to the Userform module.

Try assigning something like the following
code to your rectangle:

'==========>>
Sub Rectangle1_Click()
Dim Res As String
Const PWORD As String = "ABC" '<<==== CHANGE

Res = InputBox(Prompt:="Enter password")

If Res <> PWORD Then
MsgBox Prompt:="The password has not " _
& "been recognised!", _
Buttons:=vbCritical, _
Title:="Password"
Exit Sub
End If

'Your code to open theUserform, e.g.:
Userform1 , Show

End Sub
'<<==========



---
Regards.
Norman


TUNGANA KURMA RAJU said:
I follwed your instruction ,the user form is still opening after clicking
the
Rectangle to which I assignined the user form code

Norman Jones said:
Hi Tungana,

===========
How to protect a userform (code + object) by assigning a
password?===========

Try password protecting the VBA project:

In the VBE,

Menus | Tools | VBAProject Properties | Protection |
Lock Project for viewing [x] |
Enter and confirm Password | OK
Save, close and re-open the file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top