Chart.ApplyLayout method (Project)

Applies the specified chart layout and chart type to a selected chart.

Syntax

expression. ApplyLayout (Layout, varChartType)

expression A variable that represents a Chart object.

Parameters

Name Required/Optional Data type Description
Layout Required Long Specifies the type of layout, where the value corresponds to a Quick Layout item on the ribbon.
varChartType Optional Variant Can be one of the Office.XlChartType constants.
Layout Required INT32
varChartType Optional Variant

Return value

Nothing

Remarks

When you select a chart in a report, the Quick Layout drop-down list is on the DESIGN tab under CHART TOOLS on the ribbon. You can manually change the chart type by using the Change Chart Type command on the same ribbon tab.

When you use a layout on the current chart type, the Layout parameter is limited to the number of items in the Quick Layout drop-down list. Use the varChartType parameter to apply the layout of a different chart type on the current chart. For example, you can apply the layouts that are available from a line chart to a column chart. The ApplyLayout method adds only the line chart elements that are also available for the column chart type.

Example

The following example applies the Quick Layout item number 12 from a line chart to the selected chart.

Sub SetChartLayout()
    Dim chartShape As Shape
    Dim reportName As String
    
    reportName = "Simple scalar chart"
    Set chartShape = ActiveProject.Reports(reportName).Shapes(1)
    
    chartShape.Chart.ApplyLayout Layout:=12, varChartType:=Office.XlChartType.xlLine
End Sub

See also

Chart Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.