+ Reply to Thread
Results 1 to 16 of 16

Creating a login page with Excel

  1. #1
    Registered User
    Join Date
    07-07-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Creating a login page with Excel

    Hi, I am trying to write a code to design a login page, in which predefined usernames and passwords are set and used to identify the user logging in into the page.

    I have two problems that I would really appreciate if anyone could help me solve them:
    1) When excel prompts me to enable macros, if I just click cancel, the excel workbook will open normally and the any user can edit/change and read the remaining sheets in the workbook. How can I make the whole workbook to close if the macro is disabled?

    2) I want the username and password entered into the login page to be identified in another worksheet or at least to show up in a cell so I can link other logical functions to it.

    I really appreciate your help.

    Thanks

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Creating a login page with Excel

    You will want to use very hidden sheets for both issues. Very hidden sheets can only be unhidden with code. You will create ONE startup sheet that is visible. If the user chooses not to enable macros, this is the only sheet that will be visible.

    After entering a username and password successfully, you can use code to unhide any worksheets that are needed.

    I'd create one sheet to just store usernames and passwords, and leave this one very hidden always. Be sure to lock your code with a password so the users can't go in and figure out what is going on, and unhide the sheets using the vba properties.

    Note that this should not be considered fully secure, but will keep out those users with no more than average knowledge of Excel's workings.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    07-07-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Creating a login page with Excel

    Thank you Dave, it is really helpful.
    however given that I am still a beginner in programming, I have a couple of questions to ask you regarding the specific code that will show the hidden worksheets!

    shoule I write the code as part of the userform? and what type of a function should I use?

    Thanks
    T

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Creating a login page with Excel

    You should write it as part of the userform. Why don't you set it all up and code it as best your able, then post it and I'll help you fill in the gaps.

  5. #5
    Registered User
    Join Date
    07-07-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Creating a login page with Excel

    Please Login or Register  to view this content.
    Thank you so much Dave!
    Last edited by TammamD; 07-07-2011 at 04:40 PM.

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Creating a login page with Excel

    Hi, please read our Forum Rules, then edit your post to include code tags. Once complete, I'll do my best to help you solve your issue.

    Thanks

  7. #7
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Creating a login page with Excel

    Thanks for adding those.

    Ok, your code looks solid. Do you just need to unhide the sheets? If so, try this:

    Please Login or Register  to view this content.
    You may want to test the username and password line, I'm not sure how the order of operations works with Ands and Ors. Best would be to keep the usernames and passwords in columns A and B of a separate sheet, and test the inputed username against the corresponding password based on that sheet. MAKE SURE YOUR SHEETS ARE VERY HIDDEN, not just hidden. Very Hidden will not show up in the list of sheets you can unhide in Excel.

  8. #8
    Registered User
    Join Date
    07-07-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Creating a login page with Excel

    Thanks a lot Dave,

    It works now! but moving to the next step, how can I make sure that after the workbook is closed, all the worksheet are again very hidden and that after the new user logs in the same process will be repeated?

    Thanks

  9. #9
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Creating a login page with Excel

    Use this code with the WOrkbook_BeforeClose event:

    Please Login or Register  to view this content.
    to hide all sheets that you previously made visible.

  10. #10
    Registered User
    Join Date
    07-07-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Creating a login page with Excel

    Thank you so much Dave. You saved my day.

    I really appreciate it. my workbook now works perfectly.

    Have an awesome evening.

    Cheers

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Creating a login page with Excel

    Here's another example

    PASSWORD FORM5.zip
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  12. #12
    Registered User
    Join Date
    07-07-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Creating a login page with Excel

    thank you roy for the file!

    I have another challenge.
    The file that I am using is a daily file, that everyday the user copy the file from the day before and change its name to reflect today's date. On the other hand, I have more than one user who will be using the file, while the first one will input some changes, and I want their names to be recorded in one of the worksheets, while the two or three other users will log in after that and just needs to approve the changes done by the first user.
    My question:
    If I created a list with the corresponding names to each username pre defined, how can I make that name appers in one of the cells in "today's changes" worksheet and after that the second user to sign in, his corresponding name should be registered as authorizer for the changes made by the first user.

    I hope this is clear enough for you to help me figure out this!!
    Ireally appreciate your help.

    Thanks

  13. #13
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Creating a login page with Excel

    I'd suggest that on the username/password sheet, you add a third column to designate user/administrator, and a fourth column to correspond to the user's Environ ID. You can find which user is currently making changes by testing with code below:

    Please Login or Register  to view this content.
    Then check whether that user is the administrator or just a user.

  14. #14
    Registered User
    Join Date
    08-10-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Creating a login page with Excel

    Dude wats the password for PasswordForm5

  15. #15
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Creating a login page with Excel

    Open the workbook without enabling the macros, then unhide the sheets. The passwords are stored on the main sheet

  16. #16
    Registered User
    Join Date
    08-10-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Creating a login page with Excel

    unable to open the unhided sheets

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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