Thanks Thanks:  0
Likes Likes:  0
Results 1 to 7 of 7

Thread: password from userform

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Seattle Area, WA
    Posts
    217
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have a macro, that I want to run if the input in the userform is correct (password).

    The below macro is a simple one that I do not want to execute unless the password inputted is correct....my problem is...I do not know how to do this, I wrote the macro, and created the userform and it seems to be working ok but how do I "capture the input" and run a comparison to what the password will be in the programming....any ideas.

    UserForm1.Show
    Range("A3:H53").Select
    Range("B3").Activate
    Selection.Locked = True
    Range("E6").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="wsr"
    Range("F7").Select

  2. #2
    MrExcel MVP
    Join Date
    Apr 2002
    Location
    Vancouver BC , Canada
    Posts
    6,259
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I will assume your userform has a textbox called textbox1.
    in your code state:
    dim passwd as string
    passwd = trim(form1.textbox1.text)
    in the following line:
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="wsr"

    replace the constant "wsr" with the variable you've create ie passwd
    With

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Huntington Beach, CA USA
    Posts
    327
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,

    Try something like this:

    Private Sub CommandButton_Click()
    If TextBox1 = "wsr" Then
    'your code
    Else
    If TextBox1 <> "wsr" Then
    MsgBox"Password Failed!", vbOkOnly + _vbCritical
    End If
    End If
    End Sub

    James


    _________________


    [ This Message was edited by: James on 2002-05-06 12:21 ]

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Seattle Area, WA
    Posts
    217
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    This worked!!!!!!!!!

    But one more question.....When I bring that userfrom back up, my password is still there, how can I make it clear out each time the userform is opened?


    Russell

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Huntington Beach, CA USA
    Posts
    327
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    In the TextBox1 "Properties" scrolldown to
    PassWordChar and type *

    James

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Location
    Seattle Area, WA
    Posts
    217
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I do have it masked with that property, but the problem is the next time I pull up that userform, the input is still there, masked but still there.

    I would like to have that textbox cleared each time the userform is opened.

    Any ideas??
    Russell

  7. #7
    Board Regular
    Join Date
    Feb 2002
    Location
    Huntington Beach, CA USA
    Posts
    327
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,

    are you using the example code i posted?

    James

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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