更新时间:2023-02-12 22:03:01
问题我的是,在Excel中的图表对象实际上是一个图表表,而图表本身是一个 ChartObject 对象,并使用形状对象它在处理它。以下是链接和另一个,说明它是一个abit,以及来自此MS链接请注意,有几种不同的方法可以完成:
The problem my be that the Chart object in Excel is really a chart sheet, while a chart itself is a ChartObject object, and you use the Shape object it's in to handle it. Here's a link, and another one that talke about it a abit, and some VBA code from this MS link that shows a little of it, note that there are a few different ways to get it done:
Sub AddChart_Excel()
Dim objShape As Shape
' Create a chart and return a Shape object reference.
' The Shape object reference contains the chart.
Set objShape = ActiveSheet.Shapes.AddChart(XlChartType.xlColumnStacked100)
' Ensure the Shape object contains a chart. If so,
' set the source data for the chart to the range A1:C3.
If objShape.HasChart Then
objShape.Chart.SetSourceData Source:=Range("'Sheet1'!$A$1:$C$3")
End If
End Sub