UserName Property

Returns or sets the name of the current user. Read/write String.

Remarks

Use the UserName property to customize Microsoft Office Project 2003 options or macros for a particular user.

Suppose you have written a macro called

PrintReport

that prints the report Mine.mpp when you press CTRL+R, but another user wants to use the same shortcut keys to print the report Yours.mpp. You can edit the

PrintReport

macro so it checks the UserName property and then prints Mine.mpp if you are the current user or prints Yours.mpp if you are not.

By default, the UserName property equals the Author property.

Example

The following example sets preferences in Project according to the name of the current user.

Sub GetUserName()

    ' Prompt user for his or her name.
    UserName = InputBox$("What's your name?", , UserName)

    ' If user is Tamara, then set certain preferences.
    If UserName = "Tamara" Then
        DisplayScheduleMessages = False
        BarRounding On:=False
        Calculation = True
    ' If user is not Tamara, then set default preferences.
    Else
        DisplayScheduleMessages = True
        BarRounding On:=True
        Calculation = False
    End If

End Sub

Applies to | Profile Object, Profiles Collection Object