OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Make custom show from slides in a section

You can learn all about the new Sections object here: Sections. To make a custom show from a section. You need to first figure out the section to which the 1st slide in the selection belongs. This article assumes that there are sections already created in the presentation. If you want to add this as a button to the Section context menu see here: Context menus are back in 2010

Supported versions: PowerPoint 2010


 


		

Sub MakeCustomShowFromSection()

Dim oSld As Slide

Dim lngIndex As Long

Dim lngFirst As Long

Dim lngLast As Long

Dim lngCtr As Long

Dim SlideIDs() As Long

'Get the first slide in the selection

Set oSld = ActiveWindow.Selection.SlideRange(1)

'Figure out which section it belongs to

lngIndex = oSld.sectionIndex

'Figure out which slides need to go into the custom show

With ActivePresentation.SectionProperties

lngFirst = .FirstSlide(lngIndex)

lngLast = lngFirst + .SlidesCount(lngIndex) - 1

End With

ReDim SlideIDs(1 To 1) As Long

'Create the custom show for it

For lngCtr = lngFirst To lngLast

SlideIDs(UBound(SlideIDs)) = ActivePresentation.Slides(lngCtr).SlideID

ReDim Preserve SlideIDs(1 To UBound(SlideIDs) + 1)

Next

With ActivePresentation.SlideShowSettings.NamedSlideShows

' Delete the custom show if it already exists:

On Error Resume Next

.Item(ActivePresentation.SectionProperties.Name(lngIndex)).Delete

On Error GoTo 0

Call .Add(ActivePresentation.SectionProperties.Name(lngIndex), SlideIDs)

End With

End Sub

 
 


Copyright 1999-2022 (c) Shyam Pillai. All rights reserved.