|
-
Jun 26th, 2009, 07:19 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Get user name
I am creating a userform that will be used by a variety of users to input data into the one excel workbook. I would like the code to get the user name out of excel and onto the worksheet.
Thank you in advance.
-
Jun 26th, 2009, 07:40 AM
#2
Re: Get user name
"Out of excel" What does that mean?
It is easy as pie to get the windows login name, but I've no clue what you mean by 'out of excel'
-
Jun 26th, 2009, 08:19 AM
#3
Thread Starter
Addicted Member
Re: Get user name
If, for instance, I look at my Excel Options (the one you access through the Office button in Excel 2007), or if I look at the options that are found at the bottom of the tools drop down menu in earlier versions of Excel the copy of Excel is registered to a particular user, who can then personalise it. This is the user name I want to "get out of" Excel. (This does, of course, assume that users are logged in to the system under their own user ID. This is a reasonably safe assumption. In the event that a user is logged in under someone else's ID and is actually working the ID owner would know about it.)
-
Jun 26th, 2009, 09:16 AM
#4
Re: Get user name
I've always used the windows logon name. In my shop, the user name is actually irrelevant. It is the same for 4,000 + people and that is the name of the company.
At any rate, I found this through Google. I think it is what you are looking for (it does return the name of the company I work at when I run it)
Code:
Private Sub CommandButton1_Click()
MsgBox Application.UserName
End Sub
-
Jun 26th, 2009, 09:18 AM
#5
Re: Get user name
There is also the Environ Function in VBA.
vb Code:
Function UserNameWindows() As String
UserName = Environ("USERNAME")
End Function
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 26th, 2009, 09:22 AM
#6
Re: Get user name
That returns the windows login, not the name registered in Excel.
-
Jun 26th, 2009, 09:24 AM
#7
Re: Get user name
Ah! yes, you are right Hack...
In my company, the login name is reflected in the applicaton.username for all users in Excel...
Edit: I just checked 3 users who are on a network, and it shows their domain login names when I use Application.Username. I guess, the IT guys have made it user-specific in my company
Last edited by Siddharth Rout; Jun 26th, 2009 at 09:29 AM.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 26th, 2009, 09:29 AM
#8
Re: Get user name
Here, your windows login is your company ID badge number so I'm C123456
-
Jun 26th, 2009, 09:30 PM
#9
Thread Starter
Addicted Member
Re: Get user name
Thanks everyone! Application.UserName works a treat!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|