View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Please help Please help is offline
external usenet poster
 
Posts: 75
Default Please help with "Username"

Dave,

First of all, thank you very much for continuing to help.

Secondly, I am pulling my hairs out. I sent them a blank workbook to
populate their username as you instructed, and the populated usernames are
exactly what I have in my code. The username is in between 4 ****s. No
spaces or transpose of letters between ****s.

The populated username begins with a capitalized letter and follows by lower
case letters. I don't think that will be an issue since I have the code
below. Am I correct?

As far as lcase, the following line is in my original code:

UName = LCase(Environ("UserName"))

Thanks.

"Dave Peterson" wrote:

ps.

And send those users with problems a workbook to open that populates a cell with
their username. Tell them to save the file and return it to you.

worksheets("sheet1").range("a1").value = "****" & environ("username") & "****"

Maybe you'll see the difference.

Dave Peterson wrote:

I didn't notice that lcase() line in your original code.

I'd still guess it was a difference in spelling, though.

Please Help wrote:

Good morning Dave,

Unfortunately, the users are located in another state. I double-checked the
usernames in my code and in our addressbook. They are the same.

As far as case sensitivity, one of the lines in my code converts the
usernames to lower case. By having that line, do you think case is still an
issue?

Thanks.

"Dave Peterson" wrote:

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


--

Dave Peterson


--

Dave Peterson