Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default UserName Property

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Property value of class instance by passing string property name [email protected] Excel Programming 2 October 19th 07 05:47 PM
Runtime error 380 - Could not set the list property. Invalid property value. [email protected] Excel Programming 3 February 27th 07 06:35 AM
Could not set the ControlSource property. Invalid property value error Ömer Ayzan Excel Programming 2 October 31st 06 09:15 AM
Runtime Error 380 – Could not set the list property. Invalid property value BernzG[_16_] Excel Programming 2 August 21st 05 10:10 PM
Runtime error 380: Could not set the List property. invalid property value of listbox jasgrand Excel Programming 0 October 6th 04 09:28 PM


All times are GMT +1. The time now is 09:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"