Problems updating MS Graph charts in Powerpoint using Excel VBA 
Author Message
 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



Mon, 01 Aug 2005 20:48:02 GMT  
 Problems updating MS Graph charts in Powerpoint using Excel VBA
Alex,

I think you need

oGraph.Application.update
oGraph.Application.quit

to save the changes and release msgraph

Quote:

> 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

--

Cheers
Andy

http://www.andypope.info



Mon, 01 Aug 2005 21:15:39 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Compatibility Problem Using MS Excel 97 VBA on Excel 2000/XP - Causes crashes

2. Updating PowerPoint Presentation graphs using data from Access

3. Manipulating MS Graph 8 chart ChartTitle in VBA

4. Making a graph / chart using VB and Excel

5. Newbie - problems with MS PowerPoint & VBA

6. Really strange VBA problem (excel -> powerpoint)

7. Modifying features in MS Graph using VBA Code

8. Controling MS Graph object using VBA?

9. Using VBA to embed excel ranges and graphs in a mail item

10. access, powerpoint, and ms graph troubles

11. Image Size Problem.MS Excel Chart Export method

12. Query: Exporting VB Generated Graphs To MS PowerPoint 97

 

 
Powered by phpBB® Forum Software