我真的很希望您能在这里为我提供帮助。浏览Google / Stack溢出一百万次后,我很幸运地偶然发现了这个旧帖子。 我正在尝试使用“ copyfromrecordset”更新图表数据,并且出现诸如“下标超出范围”等错误字符串。我完全按照您的上述逻辑操作,直到执行步骤
With chtData
Set cTable = chtData.Workbook.Worksheets(1).ListObjects(1)
' Here, you can update the ListObject in the same ways you
' would do so in Excel, natively.
'在本文中,我从sql server中获取了数据并将其复制到记录集中。当我尝试更新图表数据以从记录集中获取数据时,它不起作用。 结尾为“ 你能帮我在这里吗?
非常感谢
Sub ShowChartData() Dim sld As Slide
Dim shp As Shape Dim cht As Chart Dim chtData As ChartData Dim cTable As
ObjectSet sld = ActivePresentation.Slides(1)
Set shp = sld.Shapes("New") 'Handle the chart
Set cht = shp.Chart
Set chtData = cht.ChartData chtData.ActivateWith chtData Set cTable =
chtData.Workbook,
'sql connection (hidden)
Set Cn = New ADODB.Connection
rst.Open StrQuery, Cn ' Dim wbs As Object
cTable.Range("A1:B95").CopyFromRecordset rst rst.Close