Caption Property

Applies To

Application Object, AxisTitle Object, Button Object, Buttons Collection, Characters Object, ChartTitle Object, CheckBox Object, DataLabel Object, DialogFrame Object, DrawingObjects Collection, DropDown Object, DropDowns Collection, EditBox Object, EditBoxes Collection, GroupBox Object, GroupBoxes Collection, Label Object, Labels Collection, Menu Object, MenuBar Object, MenuItem Object, OptionButton Object, OptionButtons Collection, TextBox Object, TextBoxes Collection, Window Object.

Description

The Caption property has several different meanings, depending on the object type to which it is applied. The Caption property is read-write, except as noted in the following table.

Object type

Meaning

Application

The name that appears in the title bar of the main Microsoft Excel window. If you don't set a name, or if you set the name to Empty, then this property returns "Microsoft Excel". Read-only on the Apple Macintosh.

AxisTitle

The axis title text.

Button

The button text.

Characters

The text of this range of characters.

ChartTitle

The chart title text.

Controls

The control text (check box, dialog frame, drop down, edit box, group box, label, and option button).

DataLabel

The data label text.

Menu

The name of the menu. Use an ampersand (&) before the letter that you want to be the command underline (for example, "&File").

MenuBar

The menu bar text. Read-only.

MenuItem

The name of the menu item (command). Use an ampersand (&) before the letter that you want to be the command underline (for example, "E&xit").

TextBox

The text in the text box.

Window

The name that appears in the title bar of the document window. When you set the name, you can use that name as the index to the Windows property; see the second example.


See Also

Text Property.

Example

This example sets the name that appears in the title bar of the main Microsoft Excel window to be a custom name (this can be done only in Windows; Application.Caption is read-only on the Macintosh).


Application.Caption = "Blue Sky Airlines Reservation System"

This example sets the name of the first window in the workbook to be Consolidated Balance Sheet. This name is then used as the index to the Windows method.


ActiveWorkbook.Windows(1).Caption = "Consolidated Balance Sheet"
ActiveWorkbook.Windows("Consolidated Balance Sheet") _
    .ActiveSheet.Calculate

This example changes the Open command on the File menu to Open Workbook. The example changes every menu bar in the product.


For Each mb In MenuBars
    mb.Menus("File").MenuItems(2).Caption = "&Open Workbook"
Next mb