Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rick,
Thanks for your response. What are accented letters? Basically, the usernames are the users' first initial and last name (no spaces in between first initial and last name). For example, the username that I have for John Dole in my Case statement is jdole. As far as any spaces to the names, I don't think I would have that issue because I check their names in their email properties and check with our IT department. As far as when you said "You could put a break point on the first Case statement...", I am not sure what you mean. The structure of my Case statement is similar to the following: dim UName as String UName = LCase(environ("UserName")) Select Case UName Case "jdole", "adole", "bdole", ... & _ "cdole", "ddole",..... & _ "edole","fdole" 'perform the following code Else Case 'perform the following code End Select Thanks. "Rick Rothstein" wrote: It might help if you told us the names are? Do they use any accented letters? You could put a break point on the first Case statement and then look at the contents of the UName variable to see what is actually in it. Also test to see if the user has accidentally tagged on any spaces to the name (also make sure you didn't do this on your "test against" names either). -- Rick (MVP - Excel) "Accesshelp" wrote in message ... Chip, Two years ago you helped me with the code below for username, and I am still using it. I have about 30 users on the code where you see Case "name one", "name two",.... Somehow, I am having problems with two of the usernames. Whenever these two users use the file, the file keeps saying unauthorized users. I asked them many times to make sure that the usernames that I have are correct. In addition, I asked them to go into My Computer Properties and asked them to see the username under Environment Variables. I also confirmed their usernames with my IT department. They all correct. All 30 users are located in various offices/states, and these are the only two users having problems. At this point, I don't know what causes the problems on the two users. Can you think of anything that would cause these two usernames problems? Thanks. Dim UName As String UName = LCase(Environ("UserName")) ' for to all lower case Select Case UName Case "name one", "name two", "name three" ' use lower case names ' authorized users Case Else ' unauthorized user End Select "Chip Pearson" wrote: Application.UserName is completely independent of the Windows logon name. The UserName is simply what is entered in the Options dialog. You can get the actual Windows user name with Dim UName As String UName = Environ("Username") For multiple authorized users, use code like Dim UName As String UName = LCase(Environ("UserName")) ' for to all lower case Select Case UName Case "name one", "name two", "name three" ' use lower case names ' authorized users Case Else ' unauthorized user End Select -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "AccessHelp" wrote in message ... Good morning, I have a command button in a workbook to run a macro. However, when a user clicks on the button, the macro will check first automatically whether the user who clicks on it has an authority to run the macro. If not, the user will receive a message "Access denied.". So I came up with the following code: If Application.UserName < "John Doe" Then Msgbox "Access denied." Else run the remainder of code...... End If 2 questions: 1. What does the UserName Property check against with? Does it check against with Windows user name or computer user name? When I did the code "Msgbox Application.UserName", I got my first and last names. 2. I will have more than one authorized users, and instead of having the code "If Application.UserName < "John Doe" Or If Application.UserName < "John Smith" Or ......", can you help me with better coding? Thanks. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Get Property value of class instance by passing string property name | Excel Programming | |||
Runtime error 380 - Could not set the list property. Invalid property value. | Excel Programming | |||
Could not set the ControlSource property. Invalid property value error | Excel Programming | |||
Runtime Error 380 – Could not set the list property. Invalid property value | Excel Programming | |||
Runtime error 380: Could not set the List property. invalid property value of listbox | Excel Programming |