Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to protect with Password

Hi all,

I have command button which macro has been applied to it. i would like to
protect this command button with passowrd. so, when any one click on this
command button,it should ask for a password.

Regards,
Faisal M.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to protect with Password


Hi Faisal,

Try adding the following to the code for your command button:

Private Sub CommandButton1_Click()
Dim InitialFilterValue As String
InitialFilterValue = InputBox("Please enter the password.", "PASSWORD
REQUIRED")
'To end sub if "cancel" was pressed or passowrd is wrong, sourced from
_
http://www.excelforum.com/showthread...vbcancel+input
& http://vb.mvps.org/tips/varptr.asp
If StrPtr(InitialFilterValue) = 0 Then
Exit Sub
Else
If InitialFilterValue = "secret" Then
Else
Exit Sub
End If
End If
'enter your code here
End Sub

This is just a starting point as there are ways of making it loop until
the correct password is entered or only allowing 3 tries etc.

NB: To prevent anyone opening the VB Editor to identify the password as
"secret" you will need to lock the VB Project. To do this right click on
a module/sheet code in the VBE & select VBA Project Properties - Lock
for Viewing.

hth
Rob Brockett
NZ
Always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=535313

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Need to protect with Password

You could add something like this to the top of the routine.



dim myPWD as string
dim resp as string

myPWD = "topSeCreT"
resp = inputbox(Prompt:="What's the password, Kenny?")

if resp < mypwd then
msgbox "Not authorized to use this button!
exit sub
end if


f_amshan wrote:

Hi all,

I have command button which macro has been applied to it. i would like to
protect this command button with passowrd. so, when any one click on this
command button,it should ask for a password.

Regards,
Faisal M.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Protect ub Excel Worksheet Functions 1 January 14th 09 04:46 PM
VBA password protect brian thompson3001 via OfficeKB.com New Users to Excel 1 July 16th 06 07:23 PM
Password Protect cubsfan Excel Discussion (Misc queries) 0 April 7th 06 03:34 PM
Password Protect Dedrie Excel Worksheet Functions 0 August 19th 05 07:03 PM
Is there a better way to protect our password? JK Excel Programming 1 September 3rd 04 09:21 PM


All times are GMT +1. The time now is 04:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"