#  Other Applications & Softwares  > PowerPoint Formatting & General >  >  ChartData Not Saving; Chart Not Refreshing

## desmike481

Hi - I run code from Excel to create Powerpoint presentations. I've had a great deal of success over the years, but recently, the code stopped working. When I update the ChartData, and close / save it, the chart does not refresh. In fact, it appears the ChartData doesn't appear to save. When I reopen the chart data, the edits are gone. Note- If I set a breakpoint at the save line, and step through it, it works fine.

This is the test code to repeat the issue.




```
Please Login or Register  to view this content.
```


I've tried just about everything I can think of after the update, and  before running the save command, including the following code, in an attenpt to get the updates to register before closing and saving....




```
Please Login or Register  to view this content.
```


I'm running MS Excel 2016  MSO (16.0.13001.20266) 32-bit.

Any help is appreciated. Thank you in advance.

Mike

----------


## Andy Pope

Your code worked for me using O365.

I know pp automation can be a real pain as the objects seem to lag behind the code.

I notice you do not make the powerpoint application visible. Is that just an omission in the posted code? If not try making the app visible one you create it.
Try adding DoEvents to the code before saving chartdata. I normally add a few of them with a Sleep inbetween.
Also, via code, try open/closeing  the chartdata object again

----------


## desmike481

Hey Andy. Thanks for replying. I've tried putting a number of things before the save -- including: Application.wait 1000, sleep 1000, doEvents, etc.... When I put this code in a loop and run it 10 times, even with all the waits, sleeps, and doEvents, only 20-40% of the runs work as expected. It's awfully random. 

I added a few things, and it's giving me more reliable results now:


Added powerpointApp.visible and activate commands:




```
Please Login or Register  to view this content.
```


Added mySlide.Select to make sure powerpoint has the slide activated:




```
Please Login or Register  to view this content.
```


After making chartdata updates, and before saving, run a "wasteTime" function (see myonlinetraininghub's article on pausing-or-delaying-vba-using-wait-sleep-or-a-loop). Other methods I tried, Application.wait or sleep, didn't give the same results.




```
Please Login or Register  to view this content.
```


When I implemented these changes into my production code, I had to include DoEvents, and calculate the chartdata worksheet, in addition to the wasteTime call:




```
Please Login or Register  to view this content.
```


Thanks for your attention on this issue.

Mike

----------


## Andy Pope

When I do powerpoint report automation I run from Powerpoint and create Excel application.

----------

