I have a VBA app in Excel that opens a PowerPoint Application with VISIBILITY = FALSE, opens a template, pastes in some Excel objects as metafile pics, saves it and closes it.
Now I've been tasked with updating a MSO Graphs chart that already exists in the PowerPoint Template. I used various code snippets, including this one:
http://www.mahipalreddy.com/vba/codes62684.htm#vba2
This gave me code like this:
[vba] 'get a handle on the graph object
For Each ppShape In ActSlide.Shapes
'Check to see whether shape is an OLE object.
If ppShape.Type = msoEmbeddedOLEObject Then
'Check to see whether OLE object is a Graph 2000 object.
'( ProgID is case sensitive)
If ppShape.OLEFormat.progID = "MSGraph.Chart.8" Then
'Set oGraph to the Graph object on the slide.
Set ppOLE = ppShape.OLEFormat.Object
End If
End If
Next ppShape
'update the graph data
ppOLE.Application.DataSheet.Range("D1").Value = arrIndicators(0)
ppOLE.Application.DataSheet.Range("D2").Value = 1 - arrIndicators(0)
ppOLE.Application.DataSheet.Range("C1").Value = arrIndicators(1)
ppOLE.Application.DataSheet.Range("C2").Value = 1 - arrIndicators(1)
ppOLE.Application.DataSheet.Range("B1").Value = arrIndicators(2)
ppOLE.Application.DataSheet.Range("B2").Value = 1 - arrIndicators(2)
ppOLE.Application.DataSheet.Range("A1").Value = arrIndicators(3)
ppOLE.Application.DataSheet.Range("A2").Value = 1 - arrIndicators(3)
Set ppOLE = Nothing[/vba]
I originall had a WITH statement for that last block, but I've been trying all kinds of crazy things with code to get it to work. Basically, the numbers don't update.
My current theory is that you can only edit MSO Graphs in PowerPoint WHEN PowerPoint is visible... This is becuase every code snippet I've seen has this line in it:
[vba]ppApp.Visible = msoTrue
[/vba]
However, making PowerPoint visible at this point screws up everything, becuase i don't even have a window for the presentation.
My current work around is to use an Excel Chart as a template, paste the new data in, copy the Chart, and then paste it into PowerPoint as a Metafile pic. However, it would be easier to just edit the MSO Graph Object...
Anyone run into problems with this before?