Get and Change User Name with VBA
This short tutorial will demonstrate how to use the Application.UserName method.
Get and Change Application User Name in VBA
Get User Name
You can use Application.UserName for returning or setting the name of the current user. This is the default name that shows in “macro recorded by”, new comments, “last saved by” etc..
You can display the current user’s name in a message box like this:
MsgBox "Current user is " & Application.UserName
Change User Name
You can change the current user name like this:
Application.UserName = "MonkeyCoder"
If you are interested who is the author of the current workbook, you can get it like this:
UserNameAuthor = ThisWorkbook.BuiltinDocumentProperties("Author")
You can also change it:
ThisWorkbook.BuiltinDocumentProperties("Author") = "ItsMe"
Windows user name can be obtained like this:
UserNameWindows = Environ("UserName")