Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've seen some posts on how to obtain the computer name, but how can i get
the username to display instead and tie it to a specific cell? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200708/1 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
MsgBox (Application.UserName) should do the trick S |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Environ("UserName")
You could create a UDF to return that value and call that from the worksheet. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "RebekahK20_pontiac via OfficeKB.com" <u36479@uwe wrote in message news:77147ce879aef@uwe... I've seen some posts on how to obtain the computer name, but how can i get the username to display instead and tie it to a specific cell? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200708/1 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You need this in order to use the Environ function:
Function UserNameWindows() As String UserName = Environ("USERNAME") End Function -- If this posting was helpful, please click on the Yes button. Regards, Michael Arch. "Bob Phillips" wrote: Environ("UserName") You could create a UDF to return that value and call that from the worksheet. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "RebekahK20_pontiac via OfficeKB.com" <u36479@uwe wrote in message news:77147ce879aef@uwe... I've seen some posts on how to obtain the computer name, but how can i get the username to display instead and tie it to a specific cell? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200708/1 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Forgive my ignorance, but now I'm getting an undefined variable?
And this goes in under the workbook, but how do i tell it where to put the username? Michael wrote: You need this in order to use the Environ function: Function UserNameWindows() As String UserName = Environ("USERNAME") End Function Environ("UserName") [quoted text clipped - 3 lines] I've seen some posts on how to obtain the computer name, but how can i get the username to display instead and tie it to a specific cell? -- Message posted via http://www.officekb.com |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The UserName variable is undefined. Code the UDF this way:
Function UserNameWindows() As String UserNameWindows = Environ("USERNAME") End Function and, place it inside a code module. Then, in your worksheet, use it just like a built-in function. For example, in A1, enter the formula: =UserNameWindows() -- Hope that helps. Vergel Adriano "RebekahK20_pontiac via OfficeKB.com" wrote: Forgive my ignorance, but now I'm getting an undefined variable? And this goes in under the workbook, but how do i tell it where to put the username? Michael wrote: You need this in order to use the Environ function: Function UserNameWindows() As String UserName = Environ("USERNAME") End Function Environ("UserName") [quoted text clipped - 3 lines] I've seen some posts on how to obtain the computer name, but how can i get the username to display instead and tie it to a specific cell? -- Message posted via http://www.officekb.com |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks - but I'm still getting the error #Name? in the cell in Excel
I found a reference to the following code: Public Function GetUsername() As String On Error Resume Next Dim objScript As Object Set objScript = CreateObject("WScript.NetWork") If Not objScript Is Nothing Then GetUsername = objScript.UserName End If Set objScript = Nothing End Function Public Function GetUserDisplayName() As String '--------------------8<---------------------- Set oADSystemInfo = CreateObject("ADSystemInfo") ' get user object Set oADsUser = GetObject("LDAP://" & oADSystemInfo.UserName) ' get full name of the current user GetUserDisplayName = oADsUser.displayname '--------------------8<---------------------- End Function I get an error when it gets to Set oADSystemInfo Any clue? Some odd reason I think I'm making this much more difficult than it should be. Vergel Adriano wrote: The UserName variable is undefined. Code the UDF this way: Function UserNameWindows() As String UserNameWindows = Environ("USERNAME") End Function and, place it inside a code module. Then, in your worksheet, use it just like a built-in function. For example, in A1, enter the formula: =UserNameWindows() Forgive my ignorance, but now I'm getting an undefined variable? And this goes in under the workbook, but how do i tell it where to put the [quoted text clipped - 11 lines] I've seen some posts on how to obtain the computer name, but how can i get the username to display instead and tie it to a specific cell? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200708/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Automatically add a textbox to a user form based on user requireme | Excel Programming | |||
User form ComboBox Items: Remember user entries? | Excel Programming | |||
How to: User Form to assign a user defined range to a macro variab | Excel Programming | |||
User Defined Functions - Help Text - Make it Easy for the User | Excel Programming | |||
How to: Make user click End User License Agreement acceptance | Excel Programming |