Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Capture Worksheet Password (2003)

    Am trying to capture, for error handling, what the user enters when prompted for the password to unlock a sheet. Have tried this but can not get the password to show.

    Private Sub cmdModifySheet_Click()
    Dim sAnswer As String
    On Error GoTo PasswordError

    sAnswer = ActiveSheet.Unprotect
    Exit Sub

    PasswordError:
    If err.Number = 1004 Then
    MsgBox sAnswer
    End If
    End Sub

    The MsgBox in the error handler will read: "You have entered " & sAnswer. " This is an invalid password."

    Am I wasting my time? Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Capture Worksheet Password (2003)

    Unprotect is not a function, it doesn't return anything. I don't think you can intercept the password this way. Is cmdModifySheet a command button on a userform? If not, you should create a userform.

    Place a text box txtPassword on the userform, and set its PasswordChar property to *.
    In the On Click event procedure of the command button, use

    ActiveSheet.Unprotect Password:=Me.txtPassword

  3. #3
    Star Lounger
    Join Date
    Feb 2003
    Location
    Annapolis, Maryland, USA
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Capture Worksheet Password (2003)

    Here's some unsolicited feedback from somebody who is here to get help, not give. (Believe me, I wish I could be helpful, but I'm not anywhere as savvy as Hans et al!)

    I hate the idea of somebody being able to intercept an incorrect password because I often use the same password for many websites. I'm pretty careful about the ones that contain financial or other sensitive information, but other people might not be.
    Michael Coleman
    BOMI International

  4. #4
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Capture Worksheet Password (2003)

    Thanks Hans again for your feedback. I was being lazy and was trying to see if I could trap the password. Slapped together a simple userform and was able to do what was needed.

    Michael - I absolutely concur with regards to passwords and security. The project that I am working on is an employee overtime hour tracking utility. There are two Team Leaders who will be given the password to unprotect a specific sheet to allow them to add/remove/modify employee data (e.g. employee name, overtime hours, phone number). There are only 15 or so employees for this work group so I didn't want to create a userform for this when I could give the TL's access to the sheet. All others are locked out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •