PDA

View Full Version : [SOLVED] Creating a Login page on Excel



Jack Brown
05-29-2017, 03:30 PM
Hello, I am trying to create a login page for my excel document to make sure only the correct people can access this.
Does anyone know a code for this?
Sorry, I just got started with VBA, so...:giggle

Thanks!

SamT
05-29-2017, 04:05 PM
Password Protect the Wordbook. That is a little bit more secure than writing all the passwords in plain text inside a "Log In" macro.

Jack Brown
05-29-2017, 04:14 PM
Thanks- but actually I'm not to worried about security.
It just has to look good for my teacher, so...

Paul_Hossler
05-29-2017, 05:20 PM
Try this

1. Add a blank or decorated WS ("Opening")

2. Add a pretty userform ("Logon") with a pictures, labels, etc. and two TextBoxs (tbUserName and tbPassword) and a command button (cbLogon)

3. In the ThisWorkbook module, BeforeClose event make "Opening" visible = true and all other worksheets visible=veryhidden

4. In the ThisWorkbook module, Open event make "Opening" visible = true and all other worksheets visible=veryhidden, and then load and show Logon

5. Add code to cbLogon to check tbUserName against tbPassword and count the number of attempts

6a. If they 'match', close the UF, show all the worksheets, and hide "Opening"

6b. If the don't match after 3 tries, then close the WB without saving



As Samt says, there is no real security by doing this, but if 'form' is more important than 'substance' it should be OK

PW protect the project also anyways


Post an example if you want feedback

Jack Brown
05-30-2017, 04:11 PM
That's good, thanks!