Great question, I've wanted to do this myself for a long time, so took the time to figure it out for you (and me!).
Basically, you'll want to a) loop through all NamedSlideShows
, b) find their slides by SlideID
, c) add a new presentation and then d) copy over the NamedSlideShow
slides with the original design. You can do this for one or all Custom Shows, based on how you send in the commands.
Here's an example:
Sub FindShows()
Dim p As PowerPoint.Presentation
Set p = PowerPoint.ActivePresenation
Dim cShow As PowerPoint.NamedSlideShow
For Each cShow In p.SlideShowSettings.NamedSlideShows
SaveCustomShow (cShow.Name, p)
Next
End Sub
The FindShows
sub just finds all Custom Shows in the ActivePresentation
and sends them to a routine that will create the each new presenation based on the specified Custom Show name. You can customize this as needed.
This routine below is the heart of it. There are a couple of things to note:
- To send over the slide design of the
source slide, you have to explicity
set the copied slide to use that
design.
A NamedSlideShow
will only give you
the SlideID
of the slides within it.
You can use FindBySlideID
to then
identify that slide in the original
presentation - it returns a slide
object. Then you simply copy it and
paste it with the design of the
original.
Sub SaveCustomShow(showName As String, p As Presentation)
Dim cShows As PowerPoint.NamedSlideShows
Set cShows = p.SlideShowSettings.NamedSlideShows
Dim cSlideIDs As Variant
cSlideIDs = cShows(showName).SlideIDs
Dim destinationPath As String
destinationPath = "C:\Temp\"
Dim newP As PowerPoint.Presentation
Set newP = PowerPoint.Presentations.Add(WithWindow:=False)
With newP
.SaveAs destinationPath & cShows(showName).Name
Dim s As PowerPoint.Slide
Dim e As Integer
For e = 1 To UBound(cSlideIDs)
Set s = p.Slides.FindBySlideID(SlideID:=cSlideIDs(e))
s.Copy
.Slides.Paste.Design = s.Design
Next
.Save
.Close
End With
Set newP = Nothing
End Sub
There's not any error checking in the code, so that will need to be worked out, but it works like a charm!