ChartSheetBase.ChartObjects Method (Object)


Gets an object that represents either a single embedded chart (a ChartObject object) or a collection of all the embedded charts (a ChartObjects object) on the sheet.

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

public object ChartObjects(
	object index


Type: System.Object

The name or number of the Microsoft.Office.Tools.Excel.ChartSheetBase. This argument can be an array, to specify more than one chart.

Return Value

Type: System.Object

This method is not equivalent to the Charts property. This method returns embedded charts; the Charts property returns chart sheets. Use the Chart property to return the Microsoft.Office.Interop.Excel.Chart object for an embedded chart.

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example uses the ChartObjects method to display whether the collection of embedded charts was created by Microsoft Office Excel.

private void UseChartObjects()
    Globals.Sheet1.Range["A1", "A5"].Value2 = 22;
    Globals.Sheet1.Range["B1", "B5"].Value2 = 55;

    this.SetSourceData(Globals.Sheet1.Range["A1", "B5"],
    this.ChartType = Excel.XlChartType.xlBarClustered;

    Excel.ChartObjects chartObjects =

    if (chartObjects.Creator == Excel.XlCreator.xlCreatorCode)
        MessageBox.Show("The ChartObjects was created by " + 
            "Microsoft Office Excel.");
Return to top