Class NamedSlideShow (PowerPoint VBA)

The class NamedSlideShow represents a custom slide show, which is a named subset of slides in a presentation.

Set

To use a NamedSlideShow class variable it first needs to be instantiated, for example

Dim nss as NamedSlideShow
Set nss = ActivePresentation.SlideShowSettings.NamedSlideShows(Index:=1)

The following procedures can be used to set variables of type NamedSlideShow: NamedSlideShows.Item, NamedSlideShows.Add and SlideShowSettings.NamedSlideShows

Count

Returns the number of objects in the specified collection.

Dim lngCount As Long
lngCount = ActivePresentation.SlideShowSettings.NamedSlideShows(1).Count

Delete

Deletes the specified NamedSlideShow object.

ActivePresentation.SlideShowSettings.NamedSlideShows(1).Delete

Name

You cannot use this property to set the name for a custom slide show. Use the Add method to redefine a custom slide show under a new name.

You can use the object's name in conjunction with the Item method to return a reference to the object if the Item method for the collection that contains the object takes a Variant argument. For example, if the value of the Name property for a shape is Rectangle 2, .Shapes("Rectangle 2") returns a reference to that shape.

Dim strName As String
strName = ActivePresentation.SlideShowSettings.NamedSlideShows(1).Name

Parent

Returns the parent object for the specified object.

SlideIDs

Returns an array of slide IDs for the specified named slide show.

Dim varSlideIDs As Variant
varSlideIDs = ActivePresentation.SlideShowSettings.NamedSlideShows(1).SlideIDs

NamedSlideShows.Add

Creates a new named slide show and adds it to the collection of named slide shows in the specified presentation. Returns a NamedSlideShow object that represents the new named slide show.

The name you specify when you add a named slide show is the name you use as an argument to the Run method to run the named slide show.

Syntax : expression.Add (Name, safeArrayOfSlideIDs)

Dim strName As String: strName = 
Dim lngsafeArrayOfSlideIDs() As Long: lngsafeArrayOfSlideIDs() = 
Dim nss As NamedSlideShow
Set nss = ActivePresentation.SlideShowSettings.NamedSlideShows.Add(Name:=strName, safeArrayOfSlideIDs:=lngsafeArrayOfSlideIDs())

Arguments

The following arguments are required:

Name (String) - The name of the slide show.

safeArrayOfSlideIDs (Long) - Contains the unique slide IDs of the slides to be displayed in a slide show.

NamedSlideShows.Count

Returns the number of objects in the specified collection.

Dim lngCount As Long
lngCount = ActivePresentation.SlideShowSettings.NamedSlideShows.Count

NamedSlideShows.Item

Returns a single NamedSlideShow object from the specified NamedSlideShows collection.

Syntax : expression.Item (Index)

Index: The name or index number of the single NamedSlideShow object in the collection to be returned.

Dim nss As NamedSlideShow
Set nss = ActivePresentation.SlideShowSettings.NamedSlideShows(Index:=1)

NamedSlideShows.Parent

Returns the parent object for the specified object.