If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Unlock sheet using button

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-04, 14:11
bhavesh78 bhavesh78 is offline
Registered User
 
Join Date: Dec 2004
Posts: 78
Unlock sheet using button

Hi All,

I have a sheet which is locked before distributing to users. I need to put a button on it so that the users who know the password can only unlock the sheet, else if password is blank or wrong it will display ERROR message and terminate. Any code will be useful.

Thanks.

~BS
Reply With Quote
  #2 (permalink)  
Old 12-30-04, 20:07
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 533
I have done something like this only insted of putting the code in the workbook I created an unlock file. If the user had the file installed they could lock and unlock the workbook by clicking a button. The drawback to this if an unapproved person acquired the password file they could unlock the workbook plus you have to redistribute the file whenever you changed the password or added files to the workbook list. The advantage it is quick to use and you don't have to remember or give out the password, just the unlock file. The key file is hidden from view to prevent viewing by the user. This is a shot of the workbook list where protected files are listed.



/
__________________
~

Bill
Reply With Quote
  #3 (permalink)  
Old 12-31-04, 08:12
MASARU MASARU is offline
Registered User
 
Join Date: Nov 2004
Location: London
Posts: 10
just assign this bit of code to a button (make sure that your sheet is password protected)

On Error GoTo WrongPassword
ActiveSheet.Unprotect
Exit Sub
WrongPassword:
MsgBox "Incorrect Password"
Reply With Quote
  #4 (permalink)  
Old 01-06-05, 13:43
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
It can get fancier than this, but this is a fairly quick and dirty approach:
Code:
Private Sub CommandButton1_Click()
    Dim ans As String
        ans = InputBox("Please enter a password to unlock the sheet", "Password required")
        
        If ans <> "bigdog" Then
            MsgBox "Sorry Charlie, but you got it wrong", vbInformation + vbOKOnly, "Buy Bye"
            Exit Sub
        Else: ActiveSheet.Unprotect "password"
        End If
        
End Sub
Hope that helps,

Smitty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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