ChartObjects Collection Object [Excel 2003 VBA Language Reference]

ChartObjects
Multiple objects

A collection of all the ChartObject objects on the specified chart sheet, dialog sheet, or worksheet. Each ChartObject object represents an embedded chart. The ChartObject object acts as a container for a Chart object. Properties and methods for the ChartObject object control the appearance and size of the embedded chart on the sheet.

Using the ChartObjects Collection

Use the ChartObjects method to return the ChartObjects collection. The following example deletes all the embedded charts on the worksheet named "Sheet1."

Worksheets("sheet1").ChartObjects.Delete

Use the Add method to create a new, empty embedded chart and add it to the collection. Use the ChartWizard method to add data and format the new chart. The following example creates a new embedded chart and then adds the data from cells A1:A20 as a line chart.

Dim ch As ChartObject
Set ch = Worksheets("sheet1").ChartObjects.Add(100, 30, 400, 250)
ch.Chart.ChartWizard source:=Worksheets("sheet1").Range("a1:a20"), _
    gallery:=xlLine, title:="New Chart"

Use ChartObjects(index), where index is the embedded chart index number or name, to return a single ChartObject object. The following example sets the pattern for the chart area in embedded chart one on the worksheet named "Sheet1."

Worksheets("Sheet1").ChartObjects(1).Chart. _
    ChartArea.Interior.Pattern = xlLightDown

Properties | Application Property | Border Property | Count Property | Creator Property | Enabled Property | Height Property | Interior Property | Left Property | Locked Property | Parent Property | Placement Property | PrintObject Property | RoundedCorners Property | Shadow Property | ShapeRange Property | Top Property | Visible Property | Width Property

Methods | Add Method | BringToFront Method | Copy Method | CopyPicture Method | Cut Method | Delete Method | Duplicate Method | Item Method | Select Method | SendToBack Method

Parent Objects

Child Objects | Border Object | Interior Object | ShapeRange Object