VBA修改PPT图表数据源
Excel中可以用如下语句动态修改图表的数据源:ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SetSourceData Source:=Range("J3:O8")
请问在PPT中的图表,用VBA怎么来动态修改数据源? 我自己试了下,如果在PPT中插入Object中的Microsoft Office Excel Chart,可以获取这个对象的Sheet并修改。
但Chart的对象不知道怎么获取
Sub CommandButton1_Click()
With ActivePresentation.Slides(1)
Dim i As Integer, j As Integer
Dim strObjectName
'获取嵌入对象的名称
For i = 1 To .Shapes.Count
If .Shapes(i).Type = msoEmbeddedOLEObject Then
strObjectName = .Shapes(i).Name
End If
Next i
Dim objShapes As Object ''嵌入的对象
Dim objChart As Object''图表对象
Dim objSheet As Object''Sheet对象
Set objShapes = .Shapes(strObjectName).OLEFormat.Object
objShapes.Worksheets("Sheet1").Cells(1, 7) = "Test"
End With
End Sub 怎么不上传个附件看看?
页:
[1]