Class Slide (PowerPoint VBA)

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

The main procedures of class Slide are Copy, Delete, Select, SlideRange.Copy, SlideRange.Delete and SlideRange.Select

Set

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

Dim sld as Slide
Set sld = ActivePresentation.Slides.Range(Index:=1)

The following procedures can be used to set variables of type Slide: SlideRange.Item, Slides.Item, Slides.AddSlide, Slides.FindBySlideID, SlideShowView.LastSlideViewed, SlideShowView.Slide, View.Slide, Selection.SlideRange, Duplicate, NotesPage, SlideRange.Duplicate, SlideRange.NotesPage, Slides.Range, Slides.Paste and Presentation.Slides

Themes

Some procedures in this class have been grouped together in themes and are described on separate theme pages

Format with its procedures ApplyTheme, ApplyThemeColorScheme, BackgroundStyle, ColorScheme, CustomLayout, Layout, ThemeColorScheme, SlideRange.ApplyTheme, SlideRange.ApplyThemeColorScheme, SlideRange.BackgroundStyle, SlideRange.ColorScheme, SlideRange.CustomLayout, SlideRange.Layout and SlideRange.ThemeColorScheme
Copy with its procedures Copy and SlideRange.Copy
Data with its procedures CustomerData and SlideRange.CustomerData
Display/Show with its procedures DisplayMasterShapes, SlideShowTransition, SlideRange.DisplayMasterShapes and SlideRange.SlideShowTransition
Import/Export with its procedures Export and SlideRange.Export
Name with its procedures Name and SlideRange.Name
Print with its procedures PrintSteps and SlideRange.PrintSteps
Number with its procedures SlideNumber and SlideRange.SlideNumber

Methods

These are the main methods of the Slide class

Delete - Deletes the specified Slide object.

ActivePresentation.Slides.Range(1).Delete

Select - Selects the specified object.

ActivePresentation.Slides.Range(1).Select

SlideRange.Delete - Deletes the specified SlideRange object.

ActivePresentation.Slides.Range.Delete

SlideRange.Select - Selects the specified object.

ActivePresentation.Slides.Range.Select

Other Methods

ApplyTemplate2 - Applies a design template and theme variant to the slide.

Dim strFileName As String: strFileName = 
Dim strVariantGUID As String: strVariantGUID = 
ActivePresentation.Slides.Range(1).ApplyTemplate2 FileName:=strFileName, VariantGUID:=strVariantGUID

PublishSlides - Publishes the specified slide to the specified location.

Dim strSlideLibraryUrl As String: strSlideLibraryUrl = "https://myURL " 
ActivePresentation.Slides.Range(1).PublishSlides SlideLibraryUrl:=strSlideLibraryUrl

SlideRange.ApplyTemplate2 - Applies a design template and theme variant to the slide range.

Dim strFileName As String: strFileName = 
Dim strVariantGUID As String: strVariantGUID = 
ActivePresentation.Slides.Range.ApplyTemplate2 FileName:=strFileName, VariantGUID:=strVariantGUID

SlideRange.PublishSlides - Creates a Web presentation (in HTML format) from any loaded presentation. You can view the published presentation in a web browser.

Dim strSlideLibraryUrl As String: strSlideLibraryUrl = 
ActivePresentation.Slides.Range.PublishSlides SlideLibraryUrl:=strSlideLibraryUrl

Slides.AddSlide - Creates a new slide, adds it to the Slides collection, and returns the slide.

Dim lngIndex As Long: lngIndex = 
Dim sldAddSlide As Slide
Set sldAddSlide = ActivePresentation.Slides.AddSlide(Index:=lngIndex, pCustomLayout:=)

Slides.InsertFromFile - Inserts slides from a file into a presentation, at the specified location. Returns an Integer that represents the number of slides inserted.

Dim strFileName As String: strFileName = "c:\ppt\sales.ppt" 
Dim lngIndex As Long: lngIndex = 2 
Dim lngInsertFromFile As Long
lngInsertFromFile = ActivePresentation.Slides.InsertFromFile(FileName:=strFileName, Index:=lngIndex)

Properties

Background returns a ShapeRange object that represents the slide background.

Dim sreBackground As ShapeRange
Set sreBackground = ActivePresentation.Slides.Range(1).Background

Comments returns a Comments object that represents a collection of comments.

Dim cmmsComments As Comments
Set cmmsComments = ActivePresentation.Slides.Range(1).Comments

Design returns a Design object representing a design.

Set ActivePresentation.Slides.Range(1).Design =

FollowMasterBackground determines whether the slide follows the slide master background.

ActivePresentation.Slides.Range(1).FollowMasterBackground = msoTrue

HasNotesPage indicates whether the selected Slide has media that resides on a notes page.

Dim mtsHasNotesPage As Office.MsoTriState
mtsHasNotesPage = ActivePresentation.Slides.Range(1).HasNotesPage

HeadersFooters returns a HeadersFooters collection that represents the header, footer, date and time, and slide number associated with the slide, slide master, or range of slides.

Dim hfsHeadersFooters As HeadersFooters
Set hfsHeadersFooters = ActivePresentation.Slides.Range(1).HeadersFooters

Hyperlinks returns a Hyperlinks collection that represents all the hyperlinks on the specified slide.

Dim hypsHyperlinks As Hyperlinks
Set hypsHyperlinks = ActivePresentation.Slides.Range(1).Hyperlinks

Master returns a Master object that represents the slide master.

Dim mstMaster As Master
Set mstMaster = ActivePresentation.Slides.Range(1).Master

NotesPage returns a SlideRange object that represents the notes pages for the specified slide or range of slides.

Dim sreNotesPage As SlideRange
Set sreNotesPage = ActivePresentation.Slides.Range(1).NotesPage

Parent returns the parent object for the specified object.

Dim objParent As Object
Set objParent = ActivePresentation.Slides.Range(1).Parent

sectionIndex returns the index of the selected section in the Slide range.

Dim lngsectionIndex As Long
lngsectionIndex = ActivePresentation.Slides.Range(1).sectionIndex

Shapes returns a Shapes collection that represents all the elements that have been placed or inserted on the specified slide, slide master, or range of slides.

Dim shpsShapes As Shapes
Set shpsShapes = ActivePresentation.Slides.Range(1).Shapes

SlideID returns a unique ID number for the specified slide.

Dim lngSlideID As Long
lngSlideID = ActivePresentation.Slides.Range(1).SlideID

SlideIndex returns the index number of the specified slide within the Slides collection.

Dim lngSlideIndex As Long
lngSlideIndex = ActivePresentation.Slides.Range(1).SlideIndex

Tags returns a Tags object that represents the tags for the specified object.

Dim tgsTags As Tags
Set tgsTags = ActivePresentation.Slides.Range(1).Tags

TimeLine returns a TimeLine object that represents the animation timeline for the slide.

Dim tleTimeLine As TimeLine
Set tleTimeLine = ActivePresentation.Slides.Range(1).TimeLine

SlideRange.Background returns a ShapeRange object that represents the slide background.

Dim sreBackground As ShapeRange
Set sreBackground = ActivePresentation.Slides.Range.Background

SlideRange.Comments returns a Comments object that represents a collection of comments.

Dim cmmsComments As Comments
Set cmmsComments = ActivePresentation.Slides.Range.Comments

SlideRange.Count returns the number of objects in the specified collection.

Dim lngCount As Long
lngCount = ActivePresentation.Slides.Range.Count

SlideRange.Design returns a Design object representing a design.

Set ActivePresentation.Slides.Range.Design =

SlideRange.FollowMasterBackground determines whether the range of slides follows the slide master background.

ActivePresentation.Slides.Range.FollowMasterBackground = msoTrue

SlideRange.HasNotesPage indicates whether the selected SlideRange has media that resides on a notes page.

Dim mtsHasNotesPage As Office.MsoTriState
mtsHasNotesPage = ActivePresentation.Slides.Range.HasNotesPage

SlideRange.HeadersFooters returns a HeadersFooters collection that represents the header, footer, date and time, and slide number associated with the slide, slide master, or range of slides.

Dim hfsHeadersFooters As HeadersFooters
Set hfsHeadersFooters = ActivePresentation.Slides.Range.HeadersFooters

SlideRange.Hyperlinks returns a Hyperlinks collection that represents all the hyperlinks on the specified slide.

Dim hypsHyperlinks As Hyperlinks
Set hypsHyperlinks = ActivePresentation.Slides.Range.Hyperlinks

SlideRange.Master returns a Master object that represents the slide master.

Dim mstMaster As Master
Set mstMaster = ActivePresentation.Slides.Range.Master

SlideRange.NotesPage returns a SlideRange object that represents the notes pages for the specified slide or range of slides.

Dim sreNotesPage As SlideRange
Set sreNotesPage = ActivePresentation.Slides.Range.NotesPage

SlideRange.Parent returns the parent object for the specified object.

Dim objParent As Object
Set objParent = ActivePresentation.Slides.Range.Parent

SlideRange.sectionIndex returns the index of the selected section in the SlideRange.

Dim lngsectionIndex As Long
lngsectionIndex = ActivePresentation.Slides.Range.sectionIndex

SlideRange.Shapes returns a Shapes collection that represents all the elements that have been placed or inserted on the specified slide, slide master, or range of slides.

Dim shpsShapes As Shapes
Set shpsShapes = ActivePresentation.Slides.Range.Shapes

SlideRange.SlideID returns a unique ID number for the specified slide.

Dim lngSlideID As Long
lngSlideID = ActivePresentation.Slides.Range.SlideID

SlideRange.SlideIndex returns the index number of the specified slide within the Slides collection.

Dim lngSlideIndex As Long
lngSlideIndex = ActivePresentation.Slides.Range.SlideIndex

SlideRange.Tags returns a Tags object that represents the tags for the specified object.

Dim tgsTags As Tags
Set tgsTags = ActivePresentation.Slides.Range.Tags

SlideRange.TimeLine returns a TimeLine object that represents the animation timeline for the slide.

Dim tleTimeLine As TimeLine
Set tleTimeLine = ActivePresentation.Slides.Range.TimeLine

Slides.Count returns the number of objects in the specified collection.

Dim lngCount As Long
lngCount = ActivePresentation.Slides.Count

Slides.Parent returns the parent object for the specified object.

Dim objParent As Object
Set objParent = ActivePresentation.Slides.Parent