+ Reply to Thread
Results 1 to 15 of 15

Require password input from all UNLESS the user is a specific name

  1. #1
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Question Require password input from all UNLESS the user is a specific name

    Afternoon Happy Campers,

    I have the following code on a workbook.
    Please Login or Register  to view this content.
    Which runs very nicely indeed. any user who opens the sheet must supply the correct password, or the sheet does not unlock.
    But i would like to know if i can get VBA to look at the windows login name of the person trying to unlock, and if it matches my own (Bloggs, Joe) then when i click the button for unlocking the sheet, VBA will bypass the need to enter the password? but for any other username it will require them to enter a password?
    Not entirely sure if its too much of a complicate thing (doubtful) or not, but im guessing im going to get the best answer from this forum!!
    (The sheet is my own creation and i also have another button with a predefined password)
    At present the sheet works, very well (with lots of input from here lol) i would just like to put the finishing touches onto it, as a kind of bragging right lol

    kind regards, galvinpaddy.

  2. #2
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Require password input from all UNLESS the user is a specific name

    and i have just noticed how much i appear to like the 'LOL' abbreviation.

    lol

  3. #3
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Require password input from all UNLESS the user is a specific name

    Try the code below on a copy of your workbook as untested

    Please Login or Register  to view this content.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  4. #4
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Require password input from all UNLESS the user is a specific name

    Hi WasWodge,
    Thanks for the effort, however it does not appear to work.

  5. #5
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Require password input from all UNLESS the user is a specific name

    That is a bit strange as I tried it later in the day on my laptop and it worked for me. Did you type in your username exactly as it is written? I.e. No different spaces. The username is the name you sign on to your pc with and it must be exactly the same as the password. On my phone until this evening and so I won't be able to test anything until then.

  6. #6
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Require password input from all UNLESS the user is a specific name

    Ah, ok.
    In excel VBA i have a function - Application.UserName
    This shows my name as Surname, Firstname - however - logging into windows itself my login is Firstname.Surname
    thanks for highlighting that, i will give it a try shortly.
    Regards.

  7. #7
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Require password input from all UNLESS the user is a specific name

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Require password input from all UNLESS the user is a specific name

    hi, thanks that has shown me my username as it should be. but still doesnt unlock all sheets.
    i have the following codes.
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    Should the codes unlock the sheet for me, without having to click the command button?
    EDIT * the code is also asking me to enter the password for all of the sheets one by one.

  9. #9
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Require password input from all UNLESS the user is a specific name

    It sounds like you need the code for your username in a workbook open event . I will have a look this evening when I get in. As for the sheets needing to have the password entered for each sheet I didn't alter your original code but again I will have a look when I get in

  10. #10
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Require password input from all UNLESS the user is a specific name

    Hi Richard, Try placing the code below in the ThisWorkbook module. Leave your original code in the standard module.

    To place code in the ThisWorkbook module

    Copy the Excel VBA code that you want to use
    Select the workbook in which you want to store the code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    In the Project Explorer, find your workbook, and open the list of Microsoft Excel Objects
    Right-click on the ThisWorkbook object, and choose View Code
    Where the cursor is flashing, choose Edit | Paste

    Please Login or Register  to view this content.
    Last edited by WasWodge; 07-02-2012 at 11:01 AM.

  11. #11
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Require password input from all UNLESS the user is a specific name

    hahahaha, fantastic, thanks very much indeed
    didnt occur to me that it would need to be in 'ThisWorkbook'
    Sincere thanks!!!

    regards, rich

  12. #12
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Require password input from all UNLESS the user is a specific name

    sorry, few final questions to this if i may, how do i add more than one username to this code, and is it possible to have a text box/user form/ etc pop up, so when it sees the name that allows the sheets to be unlocked, pops up and asks - "Unlock All?" clicking yes unlocks, clicking no leaves locked?

    kind regards.
    Last edited by galvinpaddy; 07-03-2012 at 01:30 AM.

  13. #13
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Require password input from all UNLESS the user is a specific name

    I will see if I can get a chance to have a look this evening if I get a chance when I am on my pc rather than my phone

  14. #14
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Require password input from all UNLESS the user is a specific name

    Hi Rich, try putting this in the ThisWorkbook module
    Please Login or Register  to view this content.
    And put the code below in a standard module
    Please Login or Register  to view this content.
    Please note: You should really take the solved off the post if you are adding another question.
    Last edited by WasWodge; 07-03-2012 at 10:46 PM.

  15. #15
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Require password input from all UNLESS the user is a specific name

    Fantastic code, thank-you very much indeed, greatly appreciated.
    Rep added.
    regards, galvinpaddy

+ 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