O'Reilly logo

Writing Excel Macros with VBA, 2nd Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required