Update Slides in PowerPoint using VBA

  • Thread starter Elizabeth via OfficeKB.com
  • Start date
E

Elizabeth via OfficeKB.com

I created over 200 charts that I need to update on a monthly basis. There
are four charts to on each slide. The charts are linked to Excel. I would
like to use VBA to update the presentation. I tried the attached code but
it only update the first chart on each page.

Sub RefreshTest()
Dim sl As Slide
Dim sh As Shape


On Error Resume Next

For Each sl In Application.ActivePresentation.Slides
sl.Select
For Each sh In sl.Shapes
sh.OLEFormat.DoVerb 1
ActiveWindow.Selection.Unselect
Next sh
Next sl


End Sub
 
H

Hans W. Hofmann

On Wed, 20 Apr 2005 21:27:17 GMT, "Elizabeth via OfficeKB.com"

Hi Elizabeth,
I created over 200 charts that I need to update on a monthly basis. There
are four charts to on each slide. The charts are linked to Excel. I would
like to use VBA to update the presentation. I tried the attached code but
it only update the first chart on each page.

Try this?
Sub RefreshTest()
Dim sl As Slide
Dim sh As Shape


For Each sl In Application.ActivePresentation.Slides
For Each sh In sl.Shapes
If sh.Type = msoEmbeddedOLEObject Then
If InStr(sh.OLEFormat.ProgID, "Chart") Then
sh.OLEFormat.DoVerb 1
DoEvents
End If
End If
 
E

Elizabeth via OfficeKB.com

I added the code you suggested and it's changing the format and it doesn't
run through all of the slides. I have to run the code several times before
it gets to the end.
 
H

Hans W. Hofmann

I added the code you suggested and it's changing the format and it doesn't
run through all of the slides. I have to run the code several times before
it gets to the end.

Hm, I think the Code is to fast and the OLE-Server can not to handle
multiple access? Try

With sh.OLEFormat.Object
.Application.Update
.Application.Quit
end with

or add multiple DoEvent loops...
 

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