Slide Object
Slide
Multiple objects
Represents a slide. The Slides collection contains all the Slide objects in a presentation.
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's represented by a Slide object or a SlideRange collection.
Using the Slide Object
This section describes 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
Returning a 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 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 with the ID number 265.
ActivePresentation.Slides.FindBySlideID(265).Layout = ppLayoutTitle
Returning a slide in the selection
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.
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.
ActiveWindow.Selection.SlideRange.Layout = ppLayoutTitle
Returning the slide that's currently displayed in any document window or slide show window you specify
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.
Windows(2).View.Slide.Copy
Creating a new slide
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.
ActivePresentation.Slides.Add 1, ppLayoutTitleOnly