PowerPoint Macro: Starting a Custom Slide Show

This PowerPoint VBA macro starts a custom slide show.

Macro Example

Sub StartCustomSlideShow()

  With ActivePresentation.SlideShowSettings
    .RangeType = ppShowNamedSlideShow
    .SlideShowName = "for_CEO"
    .Run
  End With

End With

Description

Starts the With statement

Sub...

  With ActivePresentation.SlideShowSettings

The 3rd line starts the With…End With statement.

This statement tells PowerPoint that following any code will apply to the slideshow-settings of an active presentation.

(Application.)ActivePresentation

  With ActivePresentation...

The Application.ActivePresentation property returns the active Presentation object.

obj-PowerPoint-Application-ActivePresentation

The ActivePresentation property is a member of the PowerPoint.Global class, so we can omit the Application property.

obj-PowerPoint-ActivePresentation

ActivePresentation.SlideShowSettings (Presentation.SlideShowSettings)

  With ActivePresentation.SlideShowSettings

The Presentation.SlideShowSettings property returns a SlideShowSettings object that represents the slide show settings for the presentation.

obj-PowerPoint-Presentation-SlideShowSettings

Sets the Type of Slide Show

Sub...

  With ActivePresentation.SlideShowSettings
    .RangeType = ppShowNamedSlideShow

The 4th line sets the type of a slide show.

The SlideShowSettings.RangeType propety returns or sets the type of a slide show to run.

obj-PowerPoint-SlideShowSettings-RangeType

We can specify the type of slide show by constants determined in the PpSlideShowRangeType enumeration.

obj-PowerPoint-PpSlideShowRangeType

In this case, we are setting to the ppPrintNamedSlideShow that means a named-slideshow or custom-slideshow.

    .RangeType = ppPrintNamedSlideShow

Sets the Name of a Custom Slideshow

Sub...

  With ActivePresentation.SlideShowSettings
    .RangeType = ppShowNamedSlideShow
    .SlideShowName = "for_CEO"

The 5th line sets the name of a custom slideshow. In this macro, I set the name “for_CEO”.

The SlideShowSettings.SlideShowName property returns or sets the custom slideshow name to run.

obj-PowerPoint-SlideShowSettings-SlideShowName

Runs the Slide Show

Sub...

  With ActivePresentation.SlideShowSettings
    .RangeType = ppShowNamedSlideShow
    .SlideShowName = "for_CEO"
    .Run

The 6th line runs the slide show by the SlideShowSettings.Run method.

obj-PowerPoint-SlideShowSettings-Run

Ends the With Structure

Sub...

  With ActivePresentation.SlideShowSettings
    .RangeType = ppShowNamedSlideShow
    .SlideShowName = "for_CEO"
    .Run
  End With

The 7th line ends the With…End With statement.

After the 7th line is evaluated, this macro ends.

Sub StartCustomSlideShow()

  With ActivePresentation.SlideShowSettings
    .RangeType = ppShowNamedSlideShow
    .SlideShowName = "for_CEO"
    .Run
  End With

End With

Properties

http://www.relief.jp/itnote/archives/powerpoint-vba-run-named-slide-show.php

Apply to

  • PowerPoint 2013
  • PowerPoint 2010
  • PowerPoint 2007