0

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

1
  • Is your chart an Excel chart? Commented Dec 30, 2010 at 9:35

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

9 Comments

well that works only if i save the project as powerpoint 2003
otherwise i get an error that says "OLEFormat(unknown member): Invalid request. This property only applies to OLE objects.
Didn't test it in 2007 nor 2010. I almost always work in 2003 mode for compatibility with my clients' machines :(. Is that Ok?
it seems that i have no other option as using the compatibility mode :(
@darkdog I'll research a little, and come back if find another way.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.