Share via


Slides Collection Object

Presentation
Aa201427.parchild(en-us,office.10).gifSlides (Slide)
Aa201427.space(en-us,office.10).gifAa201427.parchild(en-us,office.10).gif

A collection of all the Slide objects in the specified presentation.

Using the Slides Collection

This section describes how to:

  • Create a slide and add it to the collection
  • Return a single slide that you specify by name, index number, or slide ID number
  • Return a subset of the slides in the presentation
  • Apply a property or method to all the slides in the presentation at the same time

Creating a slide and adding it to the collection

Use the Slides property to return a Slides collection. Use the Add method to create a new slide and add it to the collection. The following example adds a new slide to the active presentation.

  ActivePresentation.Slides.Add 2, ppLayoutBlank

Returning a single slide that you specify by name, index number, or slide ID number

Use Slides(index), where index is the slide name or index number, or use the Slides.FindBySlideID(index), where index is the slide ID number, to return a single Slide object. The following example sets the layout for slide one in the active presentation.

  ActivePresentation.Slides(1).Layout = ppLayoutTitle

The following example sets the layout for the slide named "Big Chart" in the active presentation. Note that slides are assigned automatically generated names of the form Sliden (where n is an integer) when they're created. To assign a more meaningful name to a slide, use the Name property.

  ActivePresentation.Slides("Big Chart").Layout = ppLayoutTitle

Returning a subset of the slides in the presentation

Use Slides.Range(index), where index is the slide index number or name or an array of slide index numbers or an array of slide names, to return a SlideRange object that represents a subset of the Slides collection. The following example sets the background fill for slides one and three in the active presentation.

  With ActivePresentation.Slides.Range(Array(1, 3))
    .FollowMasterBackground = False
    .Background.Fill.PresetGradient msoGradientHorizontal, _
        1, msoGradientLateSunset
End With

Applying a property or method to all the slides in the presentation at the same time

If you want to do something to all the slides in your presentation at the same time (such as delete all of them or set a property for all of them), use Slides.Range with no argument to construct a SlideRange collection that contains all the slides in the Slides collection, and then apply the appropriate property or method to the SlideRange collection. The following example sets the background fill for all the slides in the active presentation

  With ActivePresentation.Slides.Range
    .FollowMasterBackground = False
    .Background.Fill.PresetGradient msoGradientHorizontal, _
        1, msoGradientLateSunset
End With