View Single Post
  #11   Report Post  
Jon Peltier
 
Posts: n/a
Default

Hari -

Is all you're doing changing the data that the embedded Excel workbook's
chart is based upon? Maybe I'm being dense, but I don't think you need
to activate the OLE object, or use copy-paste.

I created an Excel workbook that had a worksheet ("Sheet1") with data in
A1:A5, and a chart sheet ("Chart 1") based on this data. I shrank the
chart sheet, then copied it and pasted it as an Excel Chart Object into
a PowerPoint slide. Then I closed the Excel workbook in Excel without
saving, so it's gone.

I fiddled around with the PPT and XL Immediate windows, then came up
with this short little procedure, which I ran from another Excel workbook:

Sub GetXLinPPT()
Dim ppApp As PowerPoint.Application
Dim xlWbk As Excel.Workbook ' OLE object in ppApp

Set ppApp = GetObject(, "PowerPoint.Application")
Set xlWbk = _
ppApp.ActivePresentation.Slides(1).Shapes(1).OLEFo rmat.Object

xlWbk.Worksheets("Sheet1").Range("A1:A5").Value = _
WorksheetFunction.Transpose(Array(5, 4, 3, 2, 1))

Set xlWbk = Nothing
Set ppApp = Nothing
End Sub

The data in the OLE worksheet must have updated, because the chart
updated, and stayed updated. Then all I did was save the PowerPoint
file. When I reopened it, the changes were still there.

By not opening the OLE object, you might prevent the resizing and
repositioning it is susceptible to. This technique worked well enough
that I might even have to start using it. Hear that, Brian?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Hari Prasadh wrote:
Hi,

Im cross-posting/multi-posting this in the hope that I could get a solution.

I am facing a very strange problem (both in Office 2002 and 2003) with Excel
OLE charts in PPT. (Im programming with excel as base)

I am using code zilched from Jon P's site in order to copy data from an
excel sheet and activate a PPT application (and Slide) and an Excel OLE
object within the slide and then updating the data in it and then saving
this template with a NEW NAME.

Im using this method to update a single slide template tons of time and each
time saving it with different (but well-defined) names.

Situation: - The new data gets pasted in the Excel worksheet behind the
chart (within PPT) and then the chart also gets updated and then I do a Save
As (using code) to save it with a new name and in a new location and then
close the file.

I then exit out of the code and then open the file manually and in the slide
show mode can see the UPDATED data but if I try to get in to editing mode of
the Excel OLE chart within PPT then the chart SUDDENLY displays the old data
and the excel worksheet also displays the old data??

If I escape out of the OLE and do Ctrl + Z then it shows the data updated
through Macro.

Couple of my colleagues were running tests and they see that if they save
the file manually after updating data through Macro then the same problem
doesnt recur? Im not very sure why it is so and nor Do I know whether the
above observation about manual saving is correct for all situations.

For me manual saving is not an option.

We are also experiencing the same problem in updating excel worksheets
within PPT's.

Can anybody please guide me as to what is happening here?

Regards,
Hari
India