PDA

View Full Version : PowerPoint ChartData Reverting back to old values



swayp11
05-17-2013, 05:31 PM
I've written code to update the chart data of a chart in powerpoint:



Set myChart = pptPres.Slides(8).Shapes("Chart 10").Chart

myChart.ChartData.Activate
Set wb = myChart.ChartData.Workbook
Set ws = wb.Worksheets(1)

For i = 1 To 7
ws.Range("B" & i + 1).Value = Sheet1.Range("E" & i + 2).Value
Next


wb.Close

The data is actually updating, but when I look at the chart, the old values still exist. But, when I right click to edit data, I see the new values. Then only once I've clicked edit data and closed the edit-data-workbook manually, do the numbers on the chart actually change.

How can I get the values I enter with code to not revert back to the old values, since I will be using this code to loop through a number of slides/charts.

I've tried:


myChart.Refresh
Which hasn't worked.

Edit: Using PowerPoint 2007 and this code is running from Excel 2007.

Thanks for any help!

werafa
05-23-2013, 03:22 PM
This is a stab in the dark, but try hitting F9 with the excel chart open in editing mode. If it works, then the excel calculation mode might be set to manual. I have no idea how this works with embeded content, but this module is a counterpart to one I use a lot in excel to speed up the code execution, and might give you a start.

Public Sub ResetApp()
' settings to reset working environment at end of code execution
' may need to run this manually in event of incomplete execution of code sequence
Application.Calculation = xlCalculationAutomatic
Application.StatusBar = ""
Application.ScreenUpdating = True
End Sub

Good luck
Tim