Microsoft Office Automation with Visual FoxPro
The object model
Each Workbook has a Charts collection, which contains all of the charts in the active workbook. The Chart object contains properties that control the format and data within the chart. The SeriesCollection object stores a number of Series objects, one for each data series (a single set of data to graph) in the chart. Each Series object has a Values property, which stores the Range containing the values to plot. The Series object also has many properties to control the look of the series on the graph, such as chart type (one series can be a bar chart, while the next can be a line chart), color, borders, and so on.
The Chart object has properties to access objects that are global to the chart. For example, there are objects to format the several Axis objects, and the Floor and Walls of the PlotArea. The ChartArea (the area surrounding the chart) is formatted separately from the PlotArea (the interior of the chart, bordered on the outside by the axes). Finally, there are properties to access the Legend and ChartTitle objects.
Is it a chart or a sheet?
Excel offers two ways to place charts in a workbook. You can store the chart as an object in a worksheet, or you can store the chart as a separate worksheet (also known as a chart sheet). While the two kinds are each stored as Chart objects, they are stored in different collections, and each collection belongs to a different object.
Chart sheets are accessed through the Charts collection, and since they re worksheets, too, they can also be accessed through the Sheets collection (we recommend always using the Charts collection, because changing chart formatting on what appears to be a Sheet is quite confusing). The Charts collection is accessible through both the Application object and the Workbook object.
Embedded charts have their own collection, called ChartObjects. This collection belongs to the Worksheet object.
It is important to understand that chart sheets belong to the Workbook while embedded charts belong to the Worksheet. However, both kinds of charts are stored as the same Chart object and have the same properties and methods available for formatting the chart.
Regardless of whether it s an embedded chart or a chart sheet, if it s selected (either the chart sheet is the ActiveSheet or the embedded chart has "resize" handles), the Workbook object s ActiveChart property references the chart.
Copyright 2000 by Tamar E. Granor and Della Martin All Rights Reserved