Application.Caption Property

Project Developer Reference

Returns or sets the text in the title bar of the main window. Read/write String.

Syntax

expression.Caption

expression   A variable that represents an Application object.

Return Value
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", 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.

Visual Basic for Applications
  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.<strong class="bterm">Caption</strong> = Empty
Else
    ActiveWindow.<strong class="bterm">Caption</strong> = Entry
End If

End Sub

See Also