ChartSheet.ApplyLayout Method (2007 System)

Applies the specified layout to the chart.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Sub ApplyLayout ( _
    Layout As Integer, _
    ChartType As Object _
)
'Usage
Dim instance As ChartSheet 
Dim Layout As Integer 
Dim ChartType As Object

instance.ApplyLayout(Layout, ChartType)
public void ApplyLayout(
    int Layout,
    Object ChartType
)
public:
void ApplyLayout(
    int Layout, 
    Object^ ChartType
)
public function ApplyLayout(
    Layout : int, 
    ChartType : Object
)

Parameters

  • Layout
    Type: System.Int32

    An integer from 1 through 10 that specifies the type of layout to apply to the chart.

Remarks

The values of the Layout parameter correspond to the available options on the Chart Layouts group on the Design tab on the Ribbon. The Design tab is available when you select a chart.

Each type of chart has its own set of layout options. For example, the layout options for a pie chart are different from the layout options for a column chart. If you want to apply a layout from a different chart type, you can use the ChartType parameter to specify the chart type that the Layout parameter will refer to. For example, if you have a column chart and you want to apply a layout from a line chart, pass the XlChartTypexlLine value to the ChartType parameter. The layout only adds chart elements that are available for that particular chart type.

Optional Parameters

For information about optional parameters, see The Variable missing and Optional Parameters in Office Solutions.

Examples

The following code example applies the tenth layout that is available for the chart type of the chart in chart sheet Chart1. In addition, the example uses the SetElement method to apply further layout changes: setting the style of the chart title to be centered and to lie inside the chart grid area, adding a title for the horizontal axis, and adding a rotated title for the vertical axis. To run this code example, your workbook must contain a clustered column two-dimensional chart sheet named Chart1.

Private Sub DesignChartSheet()
    Dim myChartSheet As Microsoft.Office.Tools.Excel.ChartSheet = _
        Globals.Chart1

    myChartSheet.ApplyLayout(10)

    myChartSheet.SetElement(Microsoft.Office.Core.MsoChartElementType. _
                       msoElementChartTitleCenteredOverlay)
    myChartSheet.SetElement(Microsoft.Office.Core.MsoChartElementType. _
                       msoElementPrimaryCategoryAxisTitleHorizontal)
    myChartSheet.SetElement(Microsoft.Office.Core.MsoChartElementType. _
                       msoElementPrimaryValueAxisTitleRotated)
End Sub
private void DesignChartSheet()
{
    Microsoft.Office.Tools.Excel.ChartSheet myChartSheet  =
        Globals.Chart1;

    myChartSheet.ApplyLayout(10, myChartSheet.ChartType);

    myChartSheet.SetElement(Microsoft.Office.Core.MsoChartElementType.
                       msoElementChartTitleCenteredOverlay);
    myChartSheet.SetElement(Microsoft.Office.Core.MsoChartElementType.
                       msoElementPrimaryCategoryAxisTitleHorizontal);
    myChartSheet.SetElement(Microsoft.Office.Core.MsoChartElementType.
                       msoElementPrimaryValueAxisTitleRotated);
}

.NET Framework Security

See Also

Reference

ChartSheet Class

ChartSheet Members

Microsoft.Office.Tools.Excel Namespace