Slide Object

PowerPoint Developer Reference

Represents a slide. The Slides collection contains all the Slide objects in a presentation.

Remarks

Bb265578.vs_note(en-us,office.12).gif  Note
Don't be confused if you're trying to return a reference to a single slide but you end up with a SlideRange object. A single slide can be represented either by a Slide object or by a SlideRange collection that contains only one slide, depending on how you return a reference to the slide. For example, if you create and return a reference to a slide by using the Add method, the slide is represented by a Slide object. However, if you create and return a reference to a slide by using the Duplicate method, the slide is represented by a SlideRange collection that contains a single slide. Because all the properties and methods that apply to a Slide object also apply to a SlideRange collection that contains a single slide, you can work with the returned slide in the same way, regardless of whether it is represented by a Slide object or a SlideRange collection.

The following examples describe how to:

  • Return a slide that you specify by name, index number, or slide ID number
  • Return a slide in the selection
  • Return the slide that's currently displayed in any document window or slide show window you specify
  • Create a new slide

Example

Use Slides(index), where index is the slide name or index number, or use 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.

Visual Basic for Applications
  ActivePresentation.Slides(1).Layout = ppLayoutTitle

The following example sets the layout for the slide with the ID number 265.

Visual Basic for Applications
  ActivePresentation.Slides.FindBySlideID(265).Layout = ppLayoutTitle

Use Selection.SlideRange(index), where index is the slide name or index number within the selection, to return a single Slide object. The following example sets the layout for slide one in the selection in the active window, assuming that there's at least one slide selected.

Visual Basic for Applications
  ActiveWindow.Selection.SlideRange(1).Layout = ppLayoutTitle

If there's only one slide selected, you can use Selection.SlideRange to return a SlideRange collection that contains the selected slide. The following example sets the layout for slide one in the current selection in the active window, assuming that there's exactly one slide selected.

Visual Basic for Applications
  ActiveWindow.Selection.SlideRange.Layout = ppLayoutTitle

Use the Slide property to return the slide that's currently displayed in the specified document window or slide show window view. The following example copies the slide that's currently displayed in document window two to the Clipboard.

Visual Basic for Applications
  Windows(2).View.Slide.Copy

Use the Add method to create a new slide and add it to the presentation. The following example adds a title slide to the beginning of the active presentation.

Visual Basic for Applications
  ActivePresentation.Slides.Add 1, ppLayoutTitleOnly

See Also