Great question, I wanted to do it myself for a long time, so I took the time to figure it out for you (and me!).
Basically, you need to: a) skip all NamedSlideShows , b) find the slides on the SlideID , c) add a new presentation, and then d) copy the NamedSlideShow slides with the original design, you can do this for one or all of your custom shows, based on how you send commands.
Here is 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) 'If using PowerPoint 2010 use the following line instead: 'SaveCustomShow cShow.Name, p Next End Sub
The FindShows simply finds all the custom displays in ActivePresentation and sends them to a routine that will create each new presenation based on the specified custom display name. You can customize it as needed.
This routine below is the heart. A few things to note:
- To send a slide design to the source of the slide, you must explain to set the copied slide to use this design.
- A
NamedSlideShow will only give you SlideID slides inside it. You can use FindBySlideID to then determine what the slide in the original view is - it returns a slide object. Then you just copy it and paste it using 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 is no error checking in the code, so it will need to be developed, but it works like a charm!
source share