Please help with "Username"
Just to add to Tim's response...
Can you go to the offenders and have them run a small macro:
Option Explicit
sub testit()
debug.print "****" & environ("username") & "****"
end sub
(the ****'s are just to help the username stand out more)
Then look at the immediate window in the VBE and see if you notice the spelling
error.
I'm gonna bet that you still have a typing difference.
===========
Or your code has an uppercase letter that you're missing. You can avoid that
by:
Select case lcase(...)
case is = lcase("test1"), lcase("test2"), ....
or add a line to the top of the module that will make all text comparisons
non-case sensitive:
Option Compare Text
Please Help wrote:
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
--
Dave Peterson
|