This PowerPoint VBA macro allows us to printout a custom slideshow.
Macro Example
Sub PrintoutCustomSlideshow() With ActivePresentation With .PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With .PrintOut End With End Sub
Description
Starts the 1st With
The 3rd line starts the With…End With statement.
This statement tells PowerPoint that following code will apply to the active presentation.
Sub... With ActivePresentation
The Application.ActivePresentation property returns the active Presentation object.
The ActivePresentation property is a member of the PowerPoint.Global class, so we can omit the Application property.
Starts the 2nd With
The 5th line starts the next With…End With statement.
This statement tells PowerPoint that following code will apply to the print-options of the active presentation.
Sub... With ActivePresentation With .PrintOptions
The Presentation.PrintOptions property returns the PrintOptions object.
PrintOptions is Not a Collection
The PriontOptions is not a collection.
It is a sigle object, although the last character is “s”.
Actually, the PrintOption object is not exist.
Setting the Type of Print Range
The 6th line sets the type of print range to a custom slideshow by the PrintOptions.RangeType property.
Sub... With ActivePresentation With .PrintOptions .RangeType = ppPrintNamedSlideShow
The PrintOptions.RangeType propety returns or sets the type of print range.
PpPrintRangeType enumeration
We can specify the type of print range by constants determined in the PpPrintRangeType enumeration.
In this macro, we are setting to the ppPrintNamedSlideShow (=named-slideshow/custom-slideshow).
Setting the Name of Custom Slideshow
The 7th line sets the name of custom slideshow. In this macro, I set the name “for_CEO”.
Sub... With ActivePresentation With .PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO"
The PrintOptions.SlideShowName property returns or sets the custom slideshow name to print.
Ends the 2nd With
The 8th line ends the With…End With statement for the print-options.
Sub... With ActivePresentation With .PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With
Executes Print Out
The 10th line executes print by the Presentation.PrintOut method.
Sub... With ActivePresentation With .PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With .PrintOut
Ends the 1st With
The 12th line ends the With…End With statement for the active presentation.
Sub... With ActivePresentation With .PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With .PrintOut End With
After the 12th line is evaluated, this macro ends.
Sub PrintoutCustomSlideshow() With ActivePresentation With .PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With .PrintOut End With End Sub
Properties
http://www.relief.jp/itnote/archives/powerpoint-vba-print-named-slide-show.php
Apply to
- PowerPoint 2013
- PowerPoint 2010
- PowerPoint 2007