vba ppt chart update

S

Stan Walker

I would like to use vba to update some (but not all)
values in a ppt chart.

I tried the approach below with limited success. While it
copied the values, it also replaced all the formatting
with the default chart.

Is there any way I can update some values and still retain
formatting?

-----------

sub change_chart

dim oPPTApp As PowerPoint.Application
dim oPPTShape As PowerPoint.Shape
dim oGraph As Object
dim oPPTFile As PowerPoint.Presentation

Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue
Set oPPTFile = oPPTApp.ActivePresentation

oPPTFile.Slides(1).Select

Set oPPTShape = oPPTFile.Slides(1).Shapes(3)
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(4,
2).Value
oGraph.Application.datasheet.Range("A2").Value = Cells(5,
2).Value
oGraph.Application.datasheet.Range("A3").Value = Cells(6,
2).Value

oGraph.Application.update
oGraph.Application.quit

set oPPTApp = nothing
set oPPTShape = nothing
set oGraph = nothing
set oPPTFile = nothing

End Sub
 

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