+ Reply to Thread
Results 1 to 9 of 9

Password Prompting?

  1. #1
    Registered User
    Join Date
    03-13-2005
    Posts
    29

    Password Prompting?

    I have a workbook that tracks my daily financial information at work. I have written a new macro that resets the workbook at the end of the week. However, it is critical that this macro not be run until that time.

    Is there anyway to write a password prompt into the macro so that if someone accidentedly presses the button I have assigned to it, it is protected from being ran?

    Currently, I have the button sitting on the page as a placeholder to keep this from happening.

    Thanks,
    Scott

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon Scott

    Attached as a zipped .xls is a very simple piece of code which calls a userform asking for a password. If the password is not "password" (original eh? - feel free to change it) the code terminates, otherwise it runs.

    This utilises a userform which is why I haven't listed the code. It will not keep out someone determined to run your macro, but to the average user it should stop them getting far enough to cause a problem.

    HTH

    DominicB
    Last edited by dominicb; 08-19-2008 at 04:26 AM.

  3. #3
    Registered User
    Join Date
    03-13-2005
    Posts
    29
    Thanks, that was exactly the type of thing I was looking for. It's not so much a security feature as it is something to prevent the macro being run accidentedly.

    Scott

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    You're welcome. Thank you for the feedback.

    DominicB

  5. #5
    Registered User
    Join Date
    03-13-2005
    Posts
    29
    Everything is working exactly like I wanted now except for one thing. After running the macro, the next night when we go to run it again, the password is still in the text entry box.

    Is there a line of code that I can put in that will make sure the password is cleared after the macro runs?

    Scott

  6. #6
    Registered User
    Join Date
    03-08-2005
    Posts
    9
    Try putting:

    TextBox1.Value = ""

    just below the IF line and just below the END IF line.


    Regards,

    Ron C

  7. #7
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651
    I cant download that ZIP. DOH!!! Help please?

  8. #8
    Forum Contributor vamosj's Avatar
    Join Date
    04-23-2004
    Location
    Oregon
    MS-Off Ver
    2010
    Posts
    294

    Another way

    Another way to go is just have at the beginning of your macro the following lines

    PSW = InputBox("Please enter your Password.")
    If PSW = "Password" Then

    Else
    MsgBox ("That is incorrect")
    Exit Sub




    This way it is not put down anywhere and only shows up in the macro.
    Janos S. Vamos
    Data Systems Technician/Fire Controlman PO1(SW/AW)
    US Navy Retired


    Remember, Record Macro can be your friend for figuring out solutions.

    Good or Bad, let me know how I did by clicking on the "Add Reputation" * just to the lower left of here. it only takes a few seconds to let someone know.

  9. #9
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651
    I cut and pasted the above code but it give an error.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1