Save All Macro For PowerPoint...

bbbb1234

Board Regular
Joined
Aug 8, 2002
Messages
150
Office Version
  1. 365
Platform
  1. Windows
I have this macro in Excel:
Sub SaveAll()
Dim xWb As Workbook
For Each xWb In Application.Workbooks
If Not xWb.ReadOnly And Windows(xWb.Name).Visible Then
xWb.Save
End If
Next
End Sub

As can been seen, it works like a champ for saving all open Excel files and I have been using it for six plus months. Now I want to create one for PowerPoint but since I am not a VBA master, I am hoping someone in this forum can provide the code to SaveAll open files in PowerPoint that is equivalent to the Excel macro above.

Help would be greatly appreciated!!!!!

Many thanks in advance!!!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I have this macro in Excel:
Sub SaveAll()
Dim xWb As Workbook
For Each xWb In Application.Workbooks
If Not xWb.ReadOnly And Windows(xWb.Name).Visible Then
xWb.Save
End If
Next
End Sub

As can been seen, it works like a champ for saving all open Excel files and I have been using it for six plus months. Now I want to create one for PowerPoint but since I am not a VBA master, I am hoping someone in this forum can provide the code to SaveAll open files in PowerPoint that is equivalent to the Excel macro above.

Help would be greatly appreciated!!!!!

Many thanks in advance!!!
Hi bbbb1234,

First you will need to turn on the Developer Tab in PowerPoint to get to the VBA Editor.

The following code should do the same as your Excel VBA code but for PowerPoint.

VBA Code:
Sub SaveAllPowerPoints()
    Dim xPPT As Object ' PowerPoint.Application
    Dim xPresentation As Object ' PowerPoint.Presentation
    
    ' Check if PowerPoint is running
    On Error Resume Next
    Set xPPT = GetObject(, "PowerPoint.Application")
    On Error GoTo 0
    
    ' If PowerPoint is not running, create a new instance
    If xPPT Is Nothing Then
        Set xPPT = CreateObject("PowerPoint.Application")
    End If
    
    ' Loop through each open presentation and save if not read-only
    For Each xPresentation In xPPT.Presentations
        If Not xPresentation.ReadOnly Then
            xPresentation.Save
        End If
    Next xPresentation
    
    ' Clean up
    Set xPresentation = Nothing
    Set xPPT = Nothing
End Sub
 
Upvote 0
Hi t0ny84 -
That worked like a champ! Thanks for the response and macro code!!!
...Brett
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top