Get and Change User Name with VBA

Associated Files Download Links

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")

 

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!


<<Return to VBA Examples