Caption Property

Microsoft Excel Visual Basic

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, this property returns "Microsoft Excel". Read/write String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the AxisTitle objects.

The axis title text. Read/write String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the Characters object.

The text of this range of characters. Read-only String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the ChartTitle object.

The chart title text. Read-only String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the DataLabel object.

The data label text. Read-only String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the DisplayUnitLabel object.

The display unit label text. Read-only String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the PivotField object.

The label text for the pivot field. Read-only String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the PivotItem object.

The label text for the pivot item. Read-only String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the CubeField object.

The label text for the cube field. Read-only String.

expression.Caption

expression    Required. An expression that returns one of the above objects.

ShowCaption property as it applies to the Window object.

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). Read/write Variant.

expression.Caption

expression    Required. An expression that returns one of the above objects.

Remarks

The following table shows example values of the Caption property and related properties, given an OLAP data source with the unique name "[Europe].[France].[Paris]" and a non-OLAP data source with the item name "Paris".

Property Value (OLAP data source) Value (non-OLAP data source)
Caption Paris Paris
Name [Europe].[France].[Paris] (read-only) Paris
SourceName [Europe].[France].[Paris] (read-only) (Same as the SQL property value; read-only)
Value [Europe].[France].[Paris] (read-only) Paris

When specifying an index into the PivotItems collection, you can use the syntax shown in the following table.

Syntax (OLAP data source) Syntax (non-OLAP data source)
expression.PivotItems("[Europe].[France].[Paris]") expression.PivotItems("Paris")

When using the Item property to reference a specific member of a collection, you can use the text index names shown in the following table.

Name (OLAP data source) Name (non-OLAP data source)
[Europe].[France].[Paris] Paris

Example

This example sets the name that appears in the title bar of the main Microsoft Excel window to be a custom name.

Application.Caption = "Blue Sky Airlines Reservation System"
		

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

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