ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User form- protection and password. (https://www.excelbanter.com/excel-programming/411348-user-form-protection-password.html)

TUNGANA KURMA RAJU

User form- protection and password.
 
How to protect a userform (code + object) by assigning a password?

Norman Jones[_2_]

User form- protection and 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.



---
Regards.
Norman


TUNGANA KURMA RAJU

User form- protection and password.
 
I follwed your instruction ,the user form is still opening after clicking the
Rectangle to which I assignined the user form code

"Norman Jones" wrote:

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.



---
Regards.
Norman



Norman Jones[_2_]

User form- protection and password.
 
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" wrote in
message ...
I follwed your instruction ,the user form is still opening after clicking
the
Rectangle to which I assignined the user form code

"Norman Jones" wrote:

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.



---
Regards.
Norman




TUNGANA KURMA RAJU

User form- protection and password.
 
Thank you,Norman Jones,Its working !!!

"Norman Jones" wrote:

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" wrote in
message ...
I follwed your instruction ,the user form is still opening after clicking
the
Rectangle to which I assignined the user form code

"Norman Jones" wrote:

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.



---
Regards.
Norman





All times are GMT +1. The time now is 08:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com