Application.UserName property (Project)
Gets or sets the local name of the current user. Read/write String.
Syntax
expression.UserName
expression A variable that represents an Application object.
Remarks
The UserName property of the Application object shows the local user name. By comparison, the UserName property of the Profile object shows the logon name.
Use the UserName property to customize Project options or macros for a particular user. For example, suppose you have written a macro named PrintReport that prints the Mine.mpp report when you press CTRL+R, but another user wants to use the same shortcut keys to print the Yours.mpp report. You can edit the PrintReport macro so that it checks the UserName property and then prints Mine.mpp if you are the current user or prints Yours.mpp if you are not the current user.
Note
The UserName property is the local name but can be changed to a different value. The Author field in the Project Properties dialog box is the logon name of the user by default.
Example
The following example sets preferences according to the name of the current user.
Sub GetUserName()
' Get the user name.
UserName = InputBox$("What's your name?", , UserName)
' If user is Jeff Smith, then set certain preferences.
If UserName = "Jeff Smith" Then
DisplayScheduleMessages = False
BarRounding On:=False
Calculation = True
' Otherwise, set default preferences.
Else
DisplayScheduleMessages = True
BarRounding On:=True
Calculation = False
End If
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.