Microsoft Office Tutorials and References
In Depth Information
The Chart Object Model
These objects, in turn, can contain other objects. Consider the SeriesCollection ,
which is a collection of all Series objects in the chart. A Series object contains the
following objects:
Series
Border
Points (Collection)
Interior
Now consider the Points collection. Each Point object contains the following
objects:
Point
Border
DataLabel
Interior
Assume that you want to write code to set the text of a data label to January .
Furthermore, assume that this data label belongs to the first point of the first series
of the first chart in the first worksheet of the active workbook. Your VBA statement
needs to traverse this object hierarchy and set the Text property of the appropriate
DataLabel object.
Workbook
Worksheet
ChartObject
Chart
Series
Point
DataLabel
Here’s the statement that does the job (this is a single statement that spans
two lines):
ActiveWorkbook.Worksheets(1).ChartObjects(1).Chart.SeriesCollection(1) _
.Points(1).DataLabel.Text = “January”
Actually, it’s even a bit more complex. Setting the Text property for a
DataLabel object will generate an error if the HasDataLabel property of
the Point object is False (its default setting).
Search JabSto ::




Custom Search