Computer Languages VBScript

Using Visual Basic to Automate PowerPoint Printing

For the past three years, I have been trying to find a way to automate the tedious task of printing two copies of 30 plus PowerPoint Presentations to PDF, first as Notes Pages and then as 3 Slides Per Page Handouts.  Every six months I would spend a few hours testing various batch printing applications to see if they would complete this task for me.  Unfortunately, every time I would find they would only print the standard One Slide Per Page view without the Notes field included.

Well, Thursday of last week, I had a breakthrough!  I came across a Visual Basic script which created a new PowerPoint Presentation and manipulated the Print Options.  Eureka!  This was how I was going to solve my problem.  Instead of trolling the Internet for a batch print application, I would write one myself using Visual Basic!

I should point out that before Thursday, I had never used Visual Basic to do anything and had no idea how the language worked.  However, I have many years of experience with Java, JavaScript, PHP, and ActionScript, and I have an Internet connection, so what more could I need?  Apparently that was it, because before noon on Friday, I had a script which would scan a specific folder on my Desktop, record all of the file names, open each of them up, set the Print Options, Print to PDF, and then close the files.  A task that used to take me several hours now takes about a 10th of that time.

Having never used VBScript before, I found it fairly easy to learn. I definitely recommend it if you are trying to automate some tedious task using an MS Word product.  There is a fair amount of information online to help you.  Besides, why pay for someone else’s product that doesn’t work when you can build a simple script to do it for you and get exactly what you want 🙂

Here’s the code I created to accomplish my printing task:

Const sFolder = "D:Documents and SettingsusernameDesktopPPT_Printerto_print"

Sub makeFileList()
On Error Resume Next
Dim fso, folder, files, i
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
Set i = 0
For each folderIdx In files
If i = 0 Then
file_list(i) = sFolder & folderIdx.Name
redim preserve file_list(ubound(file_list) + 1)
file_list(i) = sFolder & folderIdx.Name
End If
i = i + 1
End Sub

Call makeFileList()

'Const ppPrintOutputThreeSlideHandouts = 3
Const ppPrintOutputNotes = 5

For j = 0 To ubound(file_list)
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objPresentation = objPPT.Presentations.Open(file_list(j))
Set objOptions = objPresentation.PrintOptions
'objOptions.OutputType = ppPrintOutputThreeSlideHandouts
objOptions.OutputType = ppPrintOutputNotes

If anyone else has ever needed to do this, I hope it helps make your life a little easier too. If you’re new to VBScript and want to know some details about how to use this script, post a comment and I’ll be happy to answer your questions.

Leave a Reply

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