Caption Property

Returns or sets the text in the title bar of the main window (Application object) or a project window (Window object). Read/write String.

Remarks

When the active window is maximized, the title bar displays the caption for both the main and active windows, separating the captions with a hyphen. For example, if the caption for the main window is "Microsoft Office Project" and the caption for the active window is "Project1", then the title bar displays "Microsoft Office Project - Project1" when the active window is maximized.

If you set the Caption property to Empty , the title bar displays a default caption. The default caption for the main window is "Microsoft Office Project".

In a project with one window, the default caption for the window is the file name of the project. In a project with multiple windows, the default caption for each window is name:n, where name is the file name of the project and n is a unique number for the window. For example, if the second window of the project "Project1" is active, the default title bar displays "Microsoft Office Project - Project1.mpp:2"

Example

The following example prompts the user to change the caption for the active window.

Sub ChangeWindowCaption()

    Dim Entry As String    ' Caption entered by user

    ' Prompt user for a new caption.
    Entry = InputBox$("Enter a new caption for the active window (enter 'reset' to set the caption to its default).")

    ' If user chooses the Cancel button, exit Sub procedure.
    If Entry = Empty Then Exit Sub

    ' Set or reset the caption.
    If Entry = "reset" Then
        ActiveWindow.Caption = Empty
    Else
        ActiveWindow.Caption = Entry
    End If

End Sub

Applies to | Application Object