PowerPoint Macro: Saving All Presentations

I’ve described a Word VBA macro that saves all documents without looping.
How is in PowerPoint?

Actually, we have to loop through for saving all files in PowerPoint.

Macro Example

Sub SaveAllPresentations()

  Dim prs As Presentation

  On Error Resume Next

  For Each prs In Presentations
    prs.Save
  Next prs

End Sub

Description

Variable Declaration

The 3rd line declares an object variable named prs represents a Presentation object.

Sub...

  Dim prs As Presentation

The Presentation object represents a single PowerPoint presentation.

obj-PowerPoint-Presentation

On Error Resume Next

A run-time error will occur at the 8th line (prs.Save), if there is a file has not saved.
The 5th line aims to ignore this run-time error.

Sub...

  Dim prs As Presentation

  On Error Resume Next

Starts Looping

The 7th line starts to loop through all the elements (=Presentation) of a collection (=Presentations).

Sub...

  Dim prs As Presentation

  On Error Resume Next

  For Each prs In Presentations

The Application.Presentations property returns the Presentations collection object.

obj-PowerPoint-Application-Presentations

Because the Presentations property is a member of the PowerPoint.Global class, we can omit the Application property.

obj-PowerPoint-Global-Presentations

The Presentations is a collection of all the Presentation objects those are currently open in PowerPoint.

obj-PowerPoint-Presentations

Saving Each Presentation File

The 8th line saves the presentation file by the Presentation.Save method.

Sub...

  Dim prs As Presentation

  On Error Resume Next

  For Each prs In Presentations
    prs.Save

obj-PowerPoint-Presentation-Save

As I mentioned above, a run-time error will occur at this 8th line, if there is a file has not saved.
So, I use On Error Resume Next statement at the 5th line.

Loops Back

The 9th line loops back to get the next presentation.

Sub...

  Dim prs As Presentation

  On Error Resume Next

  For Each prs In Presentations
    prs.Save
  Next prs

After every presentation is saved, this macro ends.

Sub SaveAllPresentations()

  Dim prs As Presentation

  On Error Resume Next

  For Each prs In Presentations
    prs.Save
  Next prs

End Sub

Properties

http://www.relief.jp/itnote/archives/powerpoint-vba-save-all-presentation-files.php

Apply to

  • PowerPoint 2013
  • PowerPoint 2010
  • PowerPoint 2007