Update Slides in PowerPoint using VBA

  • Thread starter Thread starter Elizabeth via OfficeKB.com
  • Start date 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
 
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
 
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.
 
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...
 
Back
Top