开发者

Edit Powerpoint Chart Data via VBA Script

开发者 https://www.devze.com 2023-02-01 23:34 出处:网络
i\'ve a powerpoint presentation with a chart which contains data from an excel table. 开发者_运维技巧I would like to edit this data via the powerpoint VBA editor..

i've a powerpoint presentation with a chart which contains data from an excel table.

开发者_运维技巧I would like to edit this data via the powerpoint VBA editor..

how can i do this? i cant find a way to access the data of the excel table.

greets


This code allows you to access an Excel WorkSheet embedded into a PowerPoint presentation.

Sub a()

Dim oSl As PowerPoint.Slide
Dim oSh As PowerPoint.Shape

Set oSl = ActivePresentation.Slides(1)

Set oSh = oSl.Shapes(1)

With oSh.OLEFormat.Object.Sheets(1)
    .Range("A1").Value = .Range("A1").Value + 1
    .Range("A2").Value = .Range("A2").Value - 1
End With

Set oSl = Nothing
Set oSh = Nothing

End Sub  

If the graph is linked to the data you modify, probably it'll update automagically. If not, force a re-calc.

HTH!

Edit

With the following change it works in Office 2007:

With oSh.OLEFormat.Object.WorkSheets(1)
    .Range("A1").Value = .Range("A1").Value + 1
    .Range("A2").Value = .Range("A2").Value - 1
End With
0

精彩评论

暂无评论...
验证码 换一张
取 消