Please help with "Username"
Tim,
Thanks for your response. I know which usernames are failing. I just don't
know why they are failing. As I responded to Dave, I checked the usernames
with those users, with our IT and in our addressbook. They are matched to
what I have in my code.
That is where I get frustrated. Anymore idea?
Thanks.
"Tim Zych" wrote:
19 names should not be a problem, as this select case statement handles
about 1000 characters in the first evaluation. Find out which usernames are
failing and investigate them.
Sub Test()
Dim s As String
Dim x As Long
For x = 122 To 25 Step -1
s = "test" & x
Select Case s
Case "test122", "test121", "test120", "test119", "test118",
"test117", "test116", "test115", "test114", "test113", "test112", "test111",
"test110", "test109", "test108", "test107", "test106", "test105", "test104",
"test103", "test102", "test101", "test100", "test99", "test98", "test97",
"test96", "test95", "test94", "test93", "test92", "test91", "test90",
"test89", "test88", "test87", "test86", "test85", "test84", "test83",
"test82", "test81", "test80", "test79", "test78", "test77", "test76",
"test75", "test74", "test73", "test72", "test71", "test70", "test69",
"test68", "test67", "test66", "test65", "test64", "test63", "test62",
"test61", "test60", "test59", "test58", "test57", "test56", "test55",
"test54", "test53", "test52", "test51", "test50", "test49", "test48",
"test47", "test46", "test45", "test44", "test43", "test42", "test41",
"test40", "test39", "test38", "test37", "test36", "test35", "test34",
"test33", "test32", "test31", "test30", "test29", "test28", "test27",
"test26", "test25"
' OK
Case Else
Debug.Print s & " not in list"
End Select
Next
End Sub
--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility
"Please Help" wrote in message
...
Hi Dave,
Thanks for your response. Yes, everything is in lower case. In addition,
there were no extra space or characters and transposed of characters.
That is what puzzles me. Is there a limit on how many username can be
used
for "Username"?
Thanks.
"Dave Peterson" wrote:
Are you typing the usernames in lowercase?
Are you sure that there aren't extra space characters in the name string?
I'd bet that there was a difference--maybe a couple of transposed
characters???
Please Help wrote:
Hello all,
I use the code below to validate the users who open the file. Somehow,
the
code is not recognizing two of the usernames. It keeps taking them to
the
Case Else, even though they are correct usernames. I even checked with
my IT
department to make sure that they are correct usernames. There are 19
authorized users.
Does anyone know why? Thanks.
Private Sub Auto_Open()
Dim UName As String 'Use to check for authorized user
UName = LCase(Environ("UserName"))
Select Case UName
Case "user1", "user2", "user3", "user4", "user5",.....,"user19"
Case Else
Workbooks("Workbook.xls").Windows(1).Visible = False
MsgBox "Sorry, you are not one of the authorized users for
" & _
"this file." vbCritical, "User Validator Macro"
Workbooks("Workbook.xls").Close False
End Select
Worksheets("Sheet1").Activate
End Sub
--
Dave Peterson
|