ChartSheet.ChartObjects Method (2007 System)

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.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Function ChartObjects ( _
    Index As Object _
) As Object
'Usage
Dim instance As ChartSheet 
Dim Index As Object 
Dim returnValue As Object 

returnValue = instance.ChartObjects(Index)
public Object ChartObjects(
    Object Index
)
public:
Object^ ChartObjects(
    Object^ Index
)
public function ChartObjects(
    Index : Object
) : Object

Parameters

Return Value

Type: System.Object

Remarks

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 Chart object for an embedded chart.

Optional Parameters

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

Examples

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

Private Sub UseChartObjects()
    Globals.Sheet1.Range("A1", "A5").Value2 = 22
    Globals.Sheet1.Range("B1", "B5").Value2 = 55

    Me.SetSourceData(Globals.Sheet1.Range("A1", "B5"), _
        Excel.XlRowCol.xlColumns)
    Me.ChartType = Excel.XlChartType.xlBarClustered

    Dim ChartObjects1 As Excel.ChartObjects = _
        CType(Me.ChartObjects(), Excel.ChartObjects)

    If ChartObjects1.Creator = Excel.XlCreator.xlCreatorCode Then
        MsgBox("The ChartObjects was created by Microsoft Office Excel.")
    End If 
End Sub
private void UseChartObjects()
{
    Globals.Sheet1.Range["A1", "A5"].Value2 = 22;
    Globals.Sheet1.Range["B1", "B5"].Value2 = 55;

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

    Excel.ChartObjects chartObjects =
        (Excel.ChartObjects)this.ChartObjects(missing);

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

.NET Framework Security

See Also

Reference

ChartSheet Class

ChartSheet Members

Microsoft.Office.Tools.Excel Namespace