Application.Username and environ("Username")

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi,

Application.Username and environ("Username") gives different values in excel 2007
But it does not in 2003. Both gives environ("Username").value.
Please help me how to figure this out in excel 2003.

Thanks.
Pedie;)
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
They are not the same. Change it in Excel's settings if you want the same for that part anyway.
 
Upvote 0
Ken, I want them to be different. When i use 2007, it shows Pediez for environ("username") and application.username shows Pedie Nz
I want it to be that way even in excel 2003.
Is there any way to handle this?
 
Upvote 0
As previous poster said change it in Tools>Options you should be able to set the name you want.

Application Username is the name of the User set in Excel Tools>Options
Environ("Username") is the name you registered for Windows see Control Panel >System
 
Upvote 0
Application Username is okay, that appears as it has to be. But Environ("Username") should appear different that is what i'm looking to do:biggrin:
I dont understand why it is not showing as it should i mean the Environ("Username")....i mean in 2003.
 
Upvote 0
Application Username is okay, that appears as it has to be. But Environ("Username") should appear different that is what i'm looking to do:biggrin:
I dont understand why it is not showing as it should i mean the Environ("Username")....i mean in 2003.
You aren't understanding.

Environ("username") is the user name which you log into Windows with.

Application.UserName is the user name which is set by the user when they run the program for the first time or whatever it was if you go to TOOLS > OPTIONS > GENERAL and set it under User Name.

For some business installs you may have had the Application.Username set by the IT folks to be the default of your Windows Login. If so you can go change it in the application.
 
Upvote 0
Open the Control panel and launch System Note the registered Name.

Open Excel 2003 and find the user name
Open Excel 2007 and find the user name

Excel will be different Match them up.
 
Upvote 0
I hope that the difference is clear now. It is easy to confuse the two.

It is easy to change the username in the Excel Application. Anyone using your computer can do it. Do my the menu method as was explained or by code.
e.g. In the Immediate Window of the VBE. Insert your name in place of mine and press Enter key after each line inserted separately:
Code:
Application.UserName="John Doe"
?Application.UserName
Application.UserName="Kenneth Hobson"
?Application.UserName

It is not so easy to do for the Windows username. Basically, you have to add a new user profile for a new Windows username and then log onto that account.

A few easy ways to see your Windows username as given by Environ("username").
1. In the VBE immediate window, type: ?Environ("username"), and press the enter key.
2. Click Start button, Run, and type: %username%, and press Enter key or OK.
3. Start > Run > cmd > OK > Set Username > press Enter key > Exit.
a. If you type, Set, and press Enter key after cmd above, you can see all of the environment variables and values.
 
Last edited:
Upvote 0
It is not so easy to do for the Windows username.
Actually, sadly it is VERY EASY to do. Try this out Kenneth - run this code:
Code:
Environ("username") = "Silly One"
and then check to see what your user name comes back as when you use Environ("username"). :biggrin:

That is why most of us developers actually prefer using the Windows API because that CANNOT be manipulated like that.
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top