
Problems updating MS Graph charts in Powerpoint using Excel VBA
Hi,
I have a curious problem that I would be grateful for any leads.
Basically I am using some VBA in Excel to create some presentations.
The macro runs through a series of sheets in a workbook and each sheet
relates to a Powerpoint Presentation's data. I have a template
presentation that I want to open, change the data for each chart and
textbox on the presentation according to specified values in the Excel
sheet. Then save the presentation, move onto the next Excel sheet and
carry on.
This I have done, and it's all absolutely fine, with one small
problem. When I go and re-open the presentations I've just created,
the charts all look fine with the correct data. However, if I then
select a chart and go to edit the data, the data in the MS Graph
datasheet reverts to whatever it was before in the template
presentation! Quite where it's storing the values that show up on the
chart before I go to edit it, I've no idea!
Can anyone help me please. The macro is enormous, but a sample of it
is below...
Curiously, the text boxes are absolutely fine.
Many thanks
Alex
Public oPPTApp As PowerPoint.Application
Public oPPTShape As PowerPoint.Shape
Public oGraph As Object
Public oPPTFile As PowerPoint.Presentation
Sub Temp()
Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue
Set oPPTFile = oPPTApp.Presentations.Open(Filename:=myTemplateDirectory
& "\" & myTemplateFile)
oPPTFile.Slides(11).Select
Set oPPTShape = oPPTFile.Slides(11).Shapes(1)
oPPTShape.TextFrame.TextRange.Text = myBar1Title
Set oPPTShape = oPPTFile.Slides(11).Shapes(2)
oPPTShape.TextFrame.TextRange.Text = myBar2Title
Set oPPTShape = oPPTFile.Slides(11).Shapes(3)
oPPTShape.TextFrame.TextRange.Text = myBar3Title
Set oPPTShape = oPPTFile.Slides(11).Shapes(4)
Set oGraph = oPPTShape.OLEFormat.Object
oGraph.Application.datasheet.Range("01").Value = "Fav"
oGraph.Application.datasheet.Range("02").Value = "Neutral"
oGraph.Application.datasheet.Range("03").Value = "Unfav"
oGraph.Application.datasheet.Range("A1").Value = Cells(14, 5).Value
oGraph.Application.datasheet.Range("A2").Value = Cells(15, 5).Value
oGraph.Application.datasheet.Range("A3").Value = Cells(16, 5).Value
oGraph.Application.datasheet.Range("B1").Value = Cells(14, 4).Value
oGraph.Application.datasheet.Range("B2").Value = Cells(15, 4).Value
oGraph.Application.datasheet.Range("B3").Value = Cells(16, 4).Value
oGraph.Application.datasheet.Range("C1").Value = Cells(14, 3).Value
oGraph.Application.datasheet.Range("C2").Value = Cells(15, 3).Value
oGraph.Application.datasheet.Range("C3").Value = Cells(16, 3).Value
End Sub