Removing Speaker Notes from a set of PowerPoint Presentations
Sometimes you want to prepare a set of PowerPoint presentations for distribution outside your company, and you want to remove all speaker notes from the presentations. This is easy enough to do if you only need to scrub a few presentations, but if you have a lot, then manually scrubbing each one will be tedious. Here is a bit of VBA code to iterate through all presentations (both PPT and PPTX) in a directory, removing the speaker notes from each slide in each deck. Posting this so that I can find this script the next time I need it.
This blog is inactive.
New blog: EricWhite.com/blog
Blog TOC
Sub RemoveSpeakerNotes()
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootcimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='E:DirectoryContainingPresentations'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
If objFile.Extension = "pptx" Or objFile.Extension = "ppt" Then
Set objPresentation = objPPT.Presentations.Open(objFile.Name)
Set colSlides = objPresentation.Slides
On Error Resume Next
For Each objSlide In colSlides
objSlide.NotesPage.Shapes(2).TextFrame.TextRange = ""
Next
objPresentation.Save
objPresentation.Close
End If
Next
MsgBox ("Done")
End Sub
This was from a Scripting Guy column, but was missing the On Error Resume Next.
Comments
Anonymous
May 13, 2010
Thank you! This is just what I needed.Anonymous
May 14, 2010
Seems strange to have this on your blog. I like and use VBA, but come to this blog for very different reasons - I can get this kind of thing anywhere. OpenXML is what I come here for.Anonymous
May 14, 2010
Hi Otaku, problem is, I looked elsewhere, and this info wasn't available. Actually, first I wrote this as an Open XML program, but then because we were preparing presentations for wide distribution, decided to let PowerPoint do it. And then there were several groups inside Microsoft who had the same need right now, so was posting this information here to save other folks lots of time. But I still want to post the Open XML version once I validate it to my satisfaction. :) But I really appreciate that you come here for Open XML info - document formats are my passion, although Office development follows right behind. -EricAnonymous
May 15, 2010
It's actually easier than that for new 2007/2010 formats. Sub RemoveSpeakerNotes() Dim status As MsoDocInspectorStatus Dim results As String ActivePresentation.DocumentInspectors(4).Fix status, results End SubAnonymous
July 24, 2010
You can't count on the notes text placeholder being the second shape on the notes page. There's a more reliable way of getting the text placeholder here: Show me the Notes Text www.pptfaq.com/FAQ00963.htm