{"id":55333,"date":"2008-06-18T02:10:00","date_gmt":"2008-06-18T02:10:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2008\/06\/18\/hey-scripting-guy-how-can-i-remove-the-speaker-notes-from-a-powerpoint-presentation\/"},"modified":"2008-06-18T02:10:00","modified_gmt":"2008-06-18T02:10:00","slug":"hey-scripting-guy-how-can-i-remove-the-speaker-notes-from-a-powerpoint-presentation","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-remove-the-speaker-notes-from-a-powerpoint-presentation\/","title":{"rendered":"Hey, Scripting Guy! How Can I Remove the Speaker Notes From a PowerPoint Presentation?"},"content":{"rendered":"<p><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\" class=\"nearGraphic\" \/><\/p>\n<p>Hey, Scripting Guy! We have a whole bunch of PowerPoint presentations that we would like to share with other people. However, before we make these presentations available we&rsquo;d like to remove all the speaker notes from each one. Is there a way we can use a script to remove the speaker notes from a PowerPoint presentation?<br \/>&#8212; TW<\/p>\n<p><img decoding=\"async\" height=\"5\" width=\"5\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" alt=\"Spacer\" border=\"0\" \/><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" class=\"nearGraphic\" \/><a href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><img decoding=\"async\" height=\"288\" width=\"120\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" align=\"right\" alt=\"Script Center\" border=\"0\" title=\"Script Center\" class=\"farGraphic\" \/><\/a><\/p>\n<p>Hey, TW. Before we begin, we&rsquo;d like to welcome all of you to the 935<sup>th<\/sup><i>Hey, Scripting Guy!<\/i> column. This is an incredible and exciting milestone for us and &ndash; what&rsquo;s that? Why are making such a big deal about the 935<sup>th<\/sup> column? Why don&rsquo;t we at least wait until the <i>1000<\/i><sup>th<\/sup> column? After all, at a rate of one column a day, that&rsquo;s not that far off.<\/p>\n<p>You know what? That&rsquo;s a fair enough question. As it turns out, though, 935 is a very special, almost-mystical number in many cultures throughout the world. <i>Which<\/i> cultures throughout the world? Well, we don&rsquo;t have time to list them all. But we&rsquo;re pretty sure there are a lot of them. In fact, we&rsquo;re pretty sure that there are <i>many<\/i> such cultures.<\/p>\n<p>Or at least there has to be one such culture <i>somewhere<\/i>, right? <\/p>\n<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataTable\" id=\"EVD\">\n<thead><\/thead>\n<tbody>\n<tr valign=\"top\" class=\"record\">\n<td>\n<p><b>True story<\/b>. The Scripting Guys were once told that a number of teams had complained that the Scripting Guys were extremely difficult to work with. &ldquo;Really?&rdquo; said the Scripting Guys. &ldquo;Can you name one of these teams?&rdquo; &ldquo;No,&rdquo; came the reply. &ldquo;But that doesn&rsquo;t matter. There&rsquo;s just a whole bunch of them and that&rsquo;s all there is to it.&rdquo;<\/p>\n<p>And, to be honest, that&rsquo;s probably true. Although we seem to get along just fine with <i>real<\/i> teams, we definitely have our problems with make-believe teams. No doubt these teams are upset that we&rsquo;ve taken our own make-believe, cartoon-like character &ndash; Scripting Guy Peter Costantini &ndash; and tried to pass him off as though he was a real person.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"dataTableBottomMargin\"><\/div>\n<p>At any rate, welcome again to the 935<sup>th<\/sup><i>Hey, Scripting Guy!<\/i> column. As a way to mark the occasion we originally planned to give away brand-new <a target=\"_blank\" href=\"http:\/\/www.lamborghini.com\/\"><b>Lamborghini&nbsp;Murcielagos<\/b><\/a> to the first 935 people who read the column. After we checked the current price of gas, however, we were afraid that our winners might not be all that excited with their prize: according to the U.S. Environmental Protection Agency, the Murcielago gets 8 miles per gallon. The EPA further estimates that it would take 2.5 gallons of gas to drive the Murcielago 25 miles. Based on the current price of gas in the Seattle area, that means it would cost you $11.25 to drive 25 miles. Need to make a 2,600 mile trip from Seattle to San Diego and back? Hey, no problem: that&rsquo;ll run you $1,170. <\/p>\n<p>Or you could fly roundtrip for $286. It&rsquo;s up to you.<\/p>\n<p>That&rsquo;s about the time we decided to forego the Lamborghini&nbsp;Murcielagos and substitute the next best thing: a script that can remove all the speaker notes from a Microsoft PowerPoint presentation. Please note that we didn&rsquo;t have enough money in our budget to mail individual copies of the script to the first 935 people who read this column. If you&rsquo;re one of the first 935, congratulations: you&rsquo;re a winner! If you&rsquo;re not one of the first 935, well, we hope you&rsquo;ll do the right thing and <i>not<\/i> read this column. After all, fair is fair, right?<\/p>\n<p>At any rate, here&rsquo;s the script. Congratulations again to all our winners:<\/p>\n<pre class=\"codeSample\">Set objPPT = CreateObject(\"PowerPoint.Application\")<br \/>objPPT.Visible = True<\/pre>\n<pre class=\"codeSample\">Set objPresentation = objPPT.Presentations.Open(\"C:\\Scripts\\Test.ppt\")<br \/>Set colSlides = objPresentation.Slides<\/pre>\n<pre class=\"codeSample\">For Each objSlide in colSlides<br \/>&nbsp;&nbsp;&nbsp; objSlide.NotesPage.Shapes(2).TextFrame.TextRange = \"\"<br \/>Next<\/pre>\n<p>So how does this chunk of code actually work? Well, to begin with, we create an instance of the <b>PowerPoint.Application<\/b> object and then set the <b>Visible<\/b> property to True; that gives us a running instance of PowerPoint that we can see on screen. The moment we have our instance of PowerPoint in hand we use the <b>Open<\/b> method to open the presentation C:\\Scripts\\Test.ppt, then use this line of code to retrieve a collection of all the slides in that presentation:<\/p>\n<pre class=\"codeSample\">Set colSlides = objPresentation.Slides<\/pre>\n<p>And then we stop to catch our breath for a moment. Whew!<\/p>\n<p>Fortunately it&rsquo;s all downhill from here. To begin with, we set up a For Each loop to loop through each slide in the collection. For each of those slides all we do is execute the following line of code:<\/p>\n<pre class=\"codeSample\">objSlide.NotesPage.Shapes(2).TextFrame.TextRange = \"\"<\/pre>\n<p>And you&rsquo;re right: that <i>is<\/i> a crazy-looking line of code, isn&rsquo;t it? <i>Why<\/i> is it so crazy-looking? Well, as it turns out, each slide has a <b>NotesPage<\/b> object that contains the speaker notes; the second shape on the NotesPage is a <b>TextFrame<\/b> object where the notes actually reside. To delete the notes for a given slide we simply need to set the value of the TextFrame&rsquo;s <b>TextRange<\/b> property to an empty string. <\/p>\n<p>Wow; now we <i>really<\/i> need to stop to catch our breath.<\/p>\n<p>Fortunately, though, we&rsquo;re pretty much done here; all we have to do now is &ndash; wait a minute: are you <i>sure<\/i> you&rsquo;re one of the first 935 people to read this column? Well, OK; we have to take your word for it. Anyway, all we have to do now is go back to the top of the loop and repeat the process with the next slide in the presentation. And then we go back and do it all over a third time, and then a fourth time, continuing along these same lines until we&rsquo;ve removed the notes from each and every slide in the presentation.<\/p>\n<p>Now, what if you wanted to do this for all the .PPT files in a folder? Well, that&rsquo;s easy; all you have to do is run this script:<\/p>\n<pre class=\"codeSample\">Set objPPT = CreateObject(\"PowerPoint.Application\")<br \/>objPPT.Visible = True<\/pre>\n<pre class=\"codeSample\">strComputer = \".\"<\/pre>\n<pre class=\"codeSample\">Set objWMIService = GetObject(\"winmgmts:\\\\\" &amp; strComputer &amp; \"\\root\\cimv2\")<\/pre>\n<pre class=\"codeSample\">Set FileList = objWMIService.ExecQuery _<br \/>&nbsp;&nbsp;&nbsp; (\"ASSOCIATORS OF {Win32_Directory.Name='C:\\Scripts'} Where \" _<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp; \"ResultClass = CIM_DataFile\")<\/pre>\n<pre class=\"codeSample\">For Each objFile In FileList<br \/>&nbsp;&nbsp;&nbsp; If objFile.Extension = \"ppt\" Then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set objPresentation = objPPT.Presentations.Open(objFile.Name)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set colSlides = objPresentation.Slides<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each objSlide in colSlides<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objSlide.NotesPage.Shapes(2).TextFrame.TextRange = \"\"<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objPresentation.Save<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objPresentation.Close<br \/>&nbsp;&nbsp;&nbsp; End If<br \/>Next<\/pre>\n<pre class=\"codeSample\">objPPT.Quit<\/pre>\n<p>And because someone is bound to ask, what if you <i>did<\/i> need a script that could echo back the speaker notes for an entire presentation? No problem. The following script opens the file Test.ppt and retrieves a collection consisting of all the slides in that presentation. For each slide the script echoes back the slide title (<b>objSlide.Shapes(1).TextFrame.TextRange<\/b>) and the speaker notes:<\/p>\n<pre class=\"codeSample\"><pre class=\"codeSample\">Set objPPT = CreateObject(\"PowerPoint.Application\")\nobjPPT.Visible = True\n\nSet objPresentation = objPPT.Presentations.Open(\"C:\\Scripts\\Test.ppt\")\nSet colSlides = objPresentation.Slides\n\nFor Each objSlide in colSlides\n    Wscript.Echo objSlide.Shapes(1).TextFrame.TextRange\n    Wscript.Echo objSlide.NotesPage.Shapes(2).TextFrame.TextRange\n    Wscript.Echo\nNext<\/pre>\n<p>That should do it, TW; we hope you find this script useful, and we hope you enjoyed the 935<sup>th<\/sup><i>Hey, Scripting Guy!<\/i> column. We should level with you, however: believe it or not, there really <i>isn&rsquo;t<\/i> any significance to the number 935. (Although 935 <i>was<\/i> the year when Haakon the Good, son of Harald Fairhair, reunited the Norwegian lands.) The truth is, we decided to celebrate column 935 for one reason and one reason only: when you&rsquo;re a Scripting Guy, you never know when a given column might be your last. See you all tomorrow!<\/p>\n<p>Well, probably.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! We have a whole bunch of PowerPoint presentations that we would like to share with other people. However, before we make these presentations available we&rsquo;d like to remove all the speaker notes from each one. Is there a way we can use a script to remove the speaker notes from a PowerPoint [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[129,49,3,5],"class_list":["post-55333","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-microsoft-powerpoint","tag-office","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! We have a whole bunch of PowerPoint presentations that we would like to share with other people. However, before we make these presentations available we&rsquo;d like to remove all the speaker notes from each one. Is there a way we can use a script to remove the speaker notes from a PowerPoint [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/55333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=55333"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/55333\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=55333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=55333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=55333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}