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 said:
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?