Chapter 21. The Chart Object

Excel charts are represented by Chart objects in the Excel object model. Since charts are quite complex, the Chart object is one of the most complicated in the object model.

To set the terminology, Figure 21-1 shows a typical chart that has been labeled with some of the commonly used chart-related terms.

Some chart terminology
Figure 21-1. Some chart terminology

Figure 21-2 shows the Chart object and its immediate children.

The Chart object
Figure 21-2. The Chart object

Chart Objects and ChartObject Objects

As you probably know, Excel charts can reside in a special type of sheet called a chart sheet or they can be embedded in an ordinary worksheet. Accordingly, a Chart object can represent a chart sheet (standalone chart) or an embedded chart. In the latter case, the Chart object is not contained directly in a worksheet. Rather, the worksheet contains a ChartObject object that acts as a container for the Chart object.

Thus, for instance, if we create a new chart using the chart wizard, the fourth step in the wizard displays the dialog shown in Figure 21-3.

Step 4 in the chart wizard
Figure 21-3. Step 4 in the chart wizard

If we choose the “As new sheet” option in step 4 of the chart wizard, we can access the resulting chart ...

Get Writing Excel Macros with VBA, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.