I’ve described a PowerPoint VBA macro that prints out a custom presentation.
If you want to PREVIEW a print image of custom slideshow, you can use this macro.
Macro Example
Sub PrintPreviewCustomSlideshow() With ActivePresentation.PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With ActiveWindow.ViewType = ppViewPrintPreview End Sub
Description
Starts the With statement
The 3rd line starts the With…End With statement.
Sub... With ActivePresentation.PrintOptions
This statement tells PowerPoint that following any code will apply to the print-options of active presentation.
ActivePresentation property
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.
Presentation.PrintOptions property
With ActivePresentation.PrintOptions
The Presentation.PrintOptions property (ActivePresentation.PrintOptions) returns the PrintOptions object.
Sets the Type of Print Range
The 4th line sets the type of print range to a custom slideshow.
Sub... With ActivePresentation.PrintOptions .RangeType = ppPrintNamedSlideShow
The PrintOptions.RangeType propety returns or sets the type of print range for the presentation.
We can specify the type of print range by constants determined in the PpPrintRangeType enumeration.
Sets the Name of the Custom Slideshow
The 5th line sets the name of the custom slideshow. In this macro, I set the name “for_CEO”.
Sub... With ActivePresentation.PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO"
The PrintOptions.SlideShowName property returns or sets the custom slideshow name to print.
End the With
Sub... With ActivePresentation.PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With
The 6th line ends the With…End With statement.
Previews the Print Image
Sub... With ActivePresentation.PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With ActiveWindow.ViewType = ppViewPrintPreview
The 8th line previews the print image by the DocumentWindow.ViewType property.
DocumentWindow.ViewType property returns or sets the type of the document window view.
The ActiveWindows property returns the active DocumentWindow object.
Because the ActiveWindow property is also a member of the PowerPoint.Global class, we can omit the Application property.
We can specify the type of document window view by constants determined in the PpViewType enumeration.
In this case, we set the ppViewPrintPreview.
ActiveWindow.ViewType = ppViewPrintPreview
After the 8th line is evaluated, this macro ends.
Sub PrintPreviewCustomSlideshow() With ActivePresentation.PrintOptions .RangeType = ppPrintNamedSlideShow .SlideShowName = "for_CEO" End With ActiveWindow.ViewType = ppViewPrintPreview End Sub
Properties
http://www.relief.jp/itnote/archives/powerpoint-vba-print-named-slide-show.php
Apply to
- PowerPoint 2013
- PowerPoint 2010
- PowerPoint 2007