' Clear the contents of the chart workspace. This removes
' any old charts that may already exist and leaves the chart workspace
' completely empty. One chart object is then added.
ChartSpace1.Clear
ChartSpace1.Charts.Add
Set chConstants = ChartSpace1.Constants
' Set the chart DataSource property to the spreadsheet.
' It is possible to specify multiple data sources, but this example uses only one.
ChartSpace1.DataSource = Spreadsheet1
' Add three series to the chart.
ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SeriesCollection.Add
'ChartSpace1.Charts(0).SeriesCollection.Add
' Connect the chart to data by specifying spreadsheet cell references
' for the different data dimensions.
' Notice that the series name is also bound to a spreadsheet cell. Changing
' the contents of the cell "B1" will also change the name that appears in the legend.
' If you don't want this behavior, set SeriesCollection(0).Caption instead of
' using the SetData method to bind the series name to the spreadsheet.
' Series one contains sales growth data for 1998.
' Bind the series name, the category names, and the values.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "B1"
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimCategories, chConstants.chDataBound, "A2:A5"
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimValues, chConstants.chDataBound, "B2:B5"
' Series two contains sales growth data for 1999.
ChartSpace1.Charts(0).SeriesCollection(1).SetData chConstants.chDimSeriesNames,chConstants.chDataBound, "C1"
ChartSpace1.Charts(0).SeriesCollection(1).SetData chConstants.chDimCategories,chConstants.chDataBound, "A2:A5"
ChartSpace1.Charts(0).SeriesCollection(1).SetData chConstants.chDimValues,chConstants.chDataBound, "C2:C5"
' Series two contains sales growth data for 2000.
ChartSpace1.Charts(0).SeriesCollection(2).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "D1"
ChartSpace1.Charts(0).SeriesCollection(2).SetData chConstants.chDimCategories, chConstants.chDataBound, "A2:A5"
ChartSpace1.Charts(0).SeriesCollection(2).SetData chConstants.chDimValues, chConstants.chDataBound, "D2:D5"
' Make the chart legend visible, format the left value axis as percentage,
' and specify that value gridlines are at 10% intervals.
ChartSpace1.Charts(0).HasLegend = True
ChartSpace1.Charts(0).Axes(chConstants.chAxisPositionLeft).NumberFormat = "0%"
ChartSpace1.Charts(0).Axes(chConstants.chAxisPositionLeft).MajorUnit = 0.1
End Sub
</script>
只要你装了office,office下就会有帮助资料,在你的机器上搜索OWC*.chm你就会找到很多。