• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to use Get Full Username using VBA

Dokat

Member
Hi,

I am using below code to get user login name. I was wondering if there is a way to get the full username not just the log in name

Code:
`Sub GetUserName_Environ()
    Dim ObjWshNw As Object
    Set ObjWshNw = CreateObject("WScript.Network")
   
    MsgBox ObjWshNw.UserName
    MsgBox ObjWshNw.ComputerName
    MsgBox ObjWshNw.UserDomain
End Sub
 
The code works only when i am logged onto the network. I am remote accessing it doesnt work. Thanks
 
Last edited:
Hi, Dokat!
Environment's USERNAME is the common way to retrieve Windows' name for a logged in account. You say "full user name" but that's nothing neither from Excel nor for Windows standalone environment. If you're dealing with a network connection issue please write OS detailed version, after getting sure that you have network access to administration & security features.
Regards!
 
Back
Top