![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Location: Tampa, Fla
Posts: 44
|
Insread of coding in user name and passwords, Can I use a seperate file (excel sheet) and look up usernames and password from there?
This way the user can manage the password list? |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Yes, passwords are basically strings. BUT, that would also depend on WHERE you have your passwords set !
Meaning, if you want to "read" the workbook password from another book, that's not an easy task. |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Location: Tampa, Fla
Posts: 44
|
The password file will reside in the same workbook.
Can you supply some code? thanks... |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
Hi Rick :
I've had some situations where I've wanted a password entered and used a VB Form or input box that the user types the information into. That way there are no passwords to be found by others ... is that acceptable ? Code:
Public Sub PasswordInfo()
CurrentUser = Application.UserName
Password = InputBox("Please Enter Password", "PASSWORD")
End Sub
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Feb 2002
Location: Tampa, Fla
Posts: 44
|
I have an input box to enter the password, but the password is coded in VB. I would like to keep a file for username and passwords and refer to this list in the code.
This is what I have: Dim spassword As String spassword = InputBox(prompt:="You must have a PASSWORD to view this page", Title:="PASSWORD REQURIED") If spassword = "psr" Then Sheets("Income").Select Else MsgBox "SORRY, You do not have access to this information - THANKS FOR TRYING", _ Title:="Oops!" Exit Sub End If End Sub I want to add a username and eliminate the coding of "psr" as the password. The code would lookup the username and password from this file and accept or deny the result. |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
Hi Rick , How about something like this ?
Code:
Public Sub PasswordInfo()
PsWdSheetName = "Sheet1"
EnterPassWd = InputBox("Please Enter Password", "PASSWORD")
Set c = Worksheets(PsWdSheetName).Range("a1:a" & (Cells(65536, 1).End(xlUp).Row)).Find(Application.UserName, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
StoredPasswd = Worksheets(PsWdSheetName).Cells(c.Row, c.Column + 1).Value
End If
If Trim(EnterPassWd) = Trim(StoredPasswd) Then
' put in what you want it to do here
End If
End Sub
Note that you could also prompt for username though this macro picks it up from who has logged into the application. It then looks at the password sheet.. attempts to find username in colA then takes passwd value from colb. It then matches that passwd with the one the user was prompted for. [ This Message was edited by: Nimrod on 2002-05-22 11:46 ] |
|
|
|
|
|
#7 |
|
New Member
Join Date: Feb 2002
Location: Tampa, Fla
Posts: 44
|
Nimrod
Thanks - that works IF the user is required to login the application. What if I included an inputbox for username and password? What would the code changes be? |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|