Using VBA to update embedded excel charts.

C

CR

I'm using PP and Excel 2000. I have a bunch of embedded (not linked)
excel charts that I programmatically update using a VBA macro. I'm
wondering if I'm doing this correctly since the process is EXTREMELY
flakey. Here is what I do.

1. Create a chart in Excel.

2. With Excel and PP both open I highlight the Excel chart and Copy
and Paste it into PP.

3. Here is the code I use to update a cell in the embedded Excel
chart.

'activate PP slide with embedded chart
ActiveWindow.View.GotoSlide 1

'find shape that is a chart
lngLoop = 1
Set objShape = ActivePresentation.Slides(1).Shapes(lngLoop)
Do While (objShape.Type <> 7)
lngLoop = lngLoop + 1
Set objShape = ActivePresentation.Slides(1).Shapes(lngLoop)
Loop

'get objSheet
Set objBook = objShape.OLEFormat.Object
Set objSheet = objBook.Sheets("Data")

'update cell
objSheet.Cells(1,1) = "10"

I get a variety of problems when I do this. All appear at random.
Sometimes when I paste the excel chart into PP, PP decides to only
display part of the chart. Sometimes when I populate the chart using
the macro, PP decides to change the size of the chart. Sometimes the
labels on the Data table overlap the labels on the X-axis for no
apparent reason. Sometimes when I "open" the embedded excel chart it
gets into this weird full screen mode where you can't resize the
window or get to the worksheet tabs at the bottom. I'm really getting
irritated with this. Is there a better way to do this? I was thinking
of using the PP Insert chart option instead of pasting in an excel
chart. Will that work better? Is there any documentation on this, I
couldn't find any at all.

Thanks!

Chuck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top