Microsoft Office Tutorials and References
In Depth Information
Example 21-1. Creating an Embedded Chart
left edge of the sheet and 1/2 row down from the top of the sheet. The dimensions of the chart are
8 columns wide and 20 rows high.
Example 21-1. Creating an Embedded Chart
Sub CreateAChart()
' Create an embedded chart
Dim co As ChartObject
Dim cw As Long, rh As Long
' Get data for positioning chart
cw = Columns(1).Width
rh = Rows(1).Height
' Position chart using column width and row height units
Set co = ActiveSheet.ChartObjects.Add(cw * 3, rh * 0.5, cw * 8, rh
* 20)
' Name it
co.Name = "ChartExample"
Debug.Print co.Name
Debug.Print co.Chart.Name
' Set chart type
co.Chart.ChartType = xlLine
End Sub
The output of the Debug.Print statements are:
ChartExample
Sheet1 Chart 1
The chart appears as in Figure 21-4 . (Yes, the chart is empty.)
Figure 21-4. The results of creating an embedded chart object
You may have noticed that the chart in Figure 21-4 is a trifle uninteresting. We will need to use
the various properties and methods of the Chart object (or the ChartWizard method) to create a
useful chart.
 
 
 
 
Search JabSto ::




Custom Search