Previously, I had written about how to convert your powerpoint to pdf using the built option, but recently I had the requirement to quickly do the same for multiple powerpoint files. It is rather cumbersome to open up powerpoint files one by one – some take a long time to open depending upon the file size then click on the file > export > save as pdf > write the file name. The time spent doing the same quickly adds up

Why can’t we have a simple way to “save as pdf” for powerpoint file right in the context menu. This way any powerpoint file that you may encounter you can quickly create pdf files for the same. How to do it ? Turns out it was quite easy – All it takes is a visual basic script and a registry edit. I have detailed the tutorial below to do the same

Step 1: Fire up your favourite text editor (Notepad / Sublime Text) and copy-paste the below

Option Explicit

Sub WriteLine ( strLine )
    WScript.Stdout.WriteLine strLine
End Sub

Const msoFalse = 0   ' False.
Const msoTrue = -1   ' True.

Const ppFixedFormatIntentScreen = 1 ' Intent is to view exported file on screen.
Const ppFixedFormatIntentPrint = 2  ' Intent is to print exported file.

Const ppFixedFormatTypeXPS = 1  ' XPS format
Const ppFixedFormatTypePDF = 2  ' PDF format

Const ppPrintHandoutVerticalFirst = 1   ' Slides are ordered vertically, with the first slide in the upper-left corner and the second slide below it.
Const ppPrintHandoutHorizontalFirst = 2 ' Slides are ordered horizontally, with the first slide in the upper-left corner and the second slide to the right of it.

Const ppPrintOutputSlides = 1               ' Slides
Const ppPrintOutputTwoSlideHandouts = 2     ' Two Slide Handouts
Const ppPrintOutputThreeSlideHandouts = 3   ' Three Slide Handouts
Const ppPrintOutputSixSlideHandouts = 4     ' Six Slide Handouts
Const ppPrintOutputNotesPages = 5           ' Notes Pages
Const ppPrintOutputOutline = 6              ' Outline
Const ppPrintOutputBuildSlides = 7          ' Build Slides
Const ppPrintOutputFourSlideHandouts = 8    ' Four Slide Handouts
Const ppPrintOutputNineSlideHandouts = 9    ' Nine Slide Handouts
Const ppPrintOutputOneSlideHandouts = 10    ' Single Slide Handouts

Const ppPrintAll = 1            ' Print all slides in the presentation.
Const ppPrintSelection = 2      ' Print a selection of slides.
Const ppPrintCurrent = 3        ' Print the current slide from the presentation.
Const ppPrintSlideRange = 4     ' Print a range of slides.
Const ppPrintNamedSlideShow = 5 ' Print a named slideshow.

Const ppShowAll = 1             ' Show all.
Const ppShowNamedSlideShow = 3  ' Show named slideshow.
Const ppShowSlideRange = 2      ' Show slide range.

' This is the actual script

Dim inputFile
Dim outputFile
Dim objPPT
Dim objPresentation
Dim objPrintOptions
Dim objFso

If WScript.Arguments.Count <> 2 Then
    WriteLine 'You need to specify input and output files.'
End If

inputFile = WScript.Arguments(0)
outputFile = WScript.Arguments(1)

Set objFso = CreateObject('Scripting.FileSystemObject')

If Not objFso.FileExists( inputFile ) Then
    WriteLine 'Unable to find your input file ' & inputFile
End If

If objFso.FileExists( outputFile ) Then
    WriteLine 'Your output file (' & outputFile & ') already exists!'
End If

WriteLine 'Input File:  ' & inputFile
WriteLine 'Output File: ' & outputFile

Set objPPT = CreateObject( 'PowerPoint.Application' )

objPPT.Visible = True
objPPT.Presentations.Open inputFile

Set objPresentation = objPPT.ActivePresentation
Set objPrintOptions = objPresentation.PrintOptions

objPrintOptions.Ranges.Add 1,objPresentation.Slides.Count
objPrintOptions.RangeType = ppShowAll

' Reference for this at
objPresentation.ExportAsFixedFormat outputFile, ppFixedFormatTypePDF, ppFixedFormatIntentScreen, msoTrue, ppPrintHandoutHorizontalFirst, ppPrintOutputSlides, msoFalse, objPrintOptions.Ranges(1), ppPrintAll, 'Slideshow Name', False, False, False, False, False


The above code is visual basic script which automatically runs the export to pdf command for it. This has been taken from a superuser forum

Step 2: Save the above file as pptconverter.vbs in an easily accessible location (You will require it later)

Step 3: Open up a text editor (e.g. Notepad) and copy-paste below
Ensure the path to pptconverter is changed to where you have saved pptcoverter.vbs (with backslash)

Windows Registry Editor Version 5.00

@='Save PDF here'

@='CSCRIPT \'C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\pptconverter.vbs\' \'%1\' \'%1.pdf\''

The above code creates a registry key and value inside Windows only for .pptx files

Step 4: Save the above file as ‘pptconverter.reg’ and double click on it. Accept the windows prompt for allowing changes to the registry. Click on ‘Yes’,

Step 5: Done

Right Click on any .pptx file. You will be able to view the save pdf here option

It will not take more than 5 minutes to do the same, but it will save you plenty of time in the future. Do let me know if you have a faster way of doing the same or a .exe wrapper for the above scripts to make it easier for normal users to avail the above option. Let me know in the comments below if you love this hack or have a feedback about the same.

Leave a comment

Your email address will not be published. Required fields are marked *