{"id":4238,"date":"2014-09-19T13:26:25","date_gmt":"2014-09-19T13:26:25","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/wp\/?p=4238"},"modified":"2022-08-12T11:42:47","modified_gmt":"2022-08-12T11:42:47","slug":"power-point-using-excel-vba-tutorial-part-1","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/","title":{"rendered":"Complete VBA tutorial to interact with Power point Presentations &#8211; Part &#8211; 1"},"content":{"rendered":"<p>[fusion_text]<span class='et-dropcap'>D<\/span><\/p>\n<p>ear Friends,<\/p>\n<p>First of all, I apologize  for not responding to many of your questions around dealing with PowerPoint presentations through Excel Macro. Many of you have sent me so many questions around this topic. Questions, which were, mostly, asked were like &#8211; <\/p>\n<div class=\"alert alert-info\">\n<h2>Sample List of Questions&#8230;<\/h2>\n<div class=\"list-group\">\n<p><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA code to create a presentation slide based on a Table in Excel<br \/>\n<i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; Excel macro to create a Slide with Graph and Table in Excel<br \/>\n<i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; Macro to paste Graph from Excel in to a PPT in a specific Slide<br \/>\n<i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA code to remove old graph from a specific slide and place the new generated graph in Excel &#8211; Like refresh button<\/p>\n<\/div>\n<\/div>\n<p>This list i just a summary what has been asked so far. Many of the questions were too specific, hence I have not mentioned them here. Therefore, I thought of writing a tutorial (more than a single article) and cover most of the aspects related to interaction with PowerPoint presentations through Exel VBA. Rather putting everything in one article, I am splitting in to more than one article. As part of this tutorial, I am sure, you will learn all the basic things (regular things) to interact with PowerPoint Presentations through Excel VBA.<br \/>\nFurthermore, you will have readily available VBA code snippets for all the basic operations, one can perform on Presentations like <em>  Open, Close, save, Copy a slide from one Presentation to other, deleting a slide, modifying the content of the slide<\/em>  and so on..<br \/>\nFinally, at the end of this <strong>tutorial<\/strong>, you will find a <strong><em>FREE Excel VBA tool to download<\/em><\/strong>. Mostly in the next article of this tutorial. <\/p>\n<h1>Topics covered in this Article<\/h1>\n<div class=\"alert alert-warning\">\n<p>Click on the links to directly jump to that particular section&#8230;<\/p>\n<div class=\"list-group\">\n<h2> <a class=\"list-group-item\" href=\"#powerpoint-object-model-in-excel-vba\"><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; Basics about Power Point Application Object Model in Excel VBA<\/h2>\n<h2> <a class=\"list-group-item\" href=\"#excel-macro-to-create-new-powerpoint-presentation\"><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA Code to create a new Presentation (Power Point Presentation File)<\/h2>\n<h2> <a class=\"list-group-item\" href=\"#excel-macro-to-add-new-slides\"><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA Code to add slides in PPT<\/em><\/h2>\n<h2>  <a class=\"list-group-item\" href=\"#excel-macro-to-save-new-presentation\"><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA Code to save a New PPT &#8211; <em>SaveAs statement<\/em><\/h2>\n<h2> <a class=\"list-group-item\" href=\"#excel-macro-to-open-powerpoint-presentation\"><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA Code to open an existing presentation file<\/h2>\n<h2> <a class=\"list-group-item\" href=\"#excel-macro-to-save-presentation\"><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA Code to save an existing presentation file &#8211; <em>Save statement<\/em><\/h2>\n<h2> <a class=\"list-group-item\" href=\"#excel-macro-to-save-presentation\"><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA Code to Save and Close powerpoint presentation<\/em><\/h2>\n<h2> <a class=\"list-group-item\" href=\"#excel-macro-to-delete-slides-from-a-presentation\"><i class=\"fa fa-file-text-o fa-fw\" aria-hidden=\"true\"><\/i>&nbsp; VBA Code to delete slides in PPT<\/em><\/h2>\n<\/div>\n<\/div>\n<p>Since we are going to access an application which is out side Microsoft Excel. Therefore to interact with that application you should have a good understanding of Objects and Methods of that application. Here in this article I am NOT going to explain you about all the Objects, Methods and Properties of PowerPoint Application but few of them to make you comfortable. To know all possible Objects, Methods, Properties and their hierarchy you can refer this page:<br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/aa213568(v=office.11).aspx\" target=\"_blank\" rel=\"noopener\">http:\/\/msdn.microsoft.com\/en-us\/library\/office\/aa213568(v=office.11).aspx<\/a>.<br \/>\n&nbsp;<\/p>\n<p><a name=\"powerpoint-object-model-in-excel-vba\"><\/a><\/p>\n<h1>VBA to Create a New Power Point Application<\/h1>\n<p>To start with any operation with any kind of PowerPoint file, you need to create an Object for the application itself. Therefore your code will always start with a statement to create an Object for PowerPoint Application:<\/p>\n<pre><code class=\"language-vbnet\">\r\nSub Create_PowerPoint_Object\r\n'Define one variable of Object Type to hold the Application Object\r\nDim objNewPowerPoint as Object\r\n'Create an Object for PowerPoint Application\r\nSet objNewPowerPoint = CreateObject(&amp;quot;PowerPoint.Application&amp;quot;)\r\nobjNewPowerPoint.Visible = True\r\nEnd Sub\r\n<\/code><\/pre>\n<p>As soon as the above line of statements are executed you can see a Power Point File launched which will look like below:<\/p>\n<img decoding=\"async\" src=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/Power-Point-Application-Object.png\" alt=\"Power-Point-Application-Object\" title=\"Power-Point-Application-Object\" width=\"432\" height=\"368\" class=\"size-full wp-image-4240\" \/>\n<p>As you can see in the above image only a simple Application is launched. It has no placeholder for presentations and Slides. This is because you have just created an Application Object.<\/p>\n<p>Now we have an Application Object so we can create multiple Presentation File from this. <\/p>\n<pre><code class=\"language-vbnet\">\r\nsub Add_Two_Presentations\r\n'Define one variable of Object Type to hold the Application Object\r\nDim objNewPowerPoint As Object\r\nDim MyPresentation1 As Object\r\nDim MyPresentation2 As Object\r\n'Create an Object for PowerPoint Application\r\nSet objNewPowerPoint = CreateObject(&amp;quot;PowerPoint.Application&amp;quot;)\r\n'Make this Application Object Visible\r\nobjNewPowerPoint.Visible = True\r\n'Create 2 presentations from that Application Object\r\nSet MyPresentation1 = objNewPowerPoint.Presentations.Add\r\nSet MyPresentation2 = objNewPowerPoint.Presentations.Add\r\nEnd Sub\r\n<\/code><\/pre>\n<p>Above code snippet will add 2 presentations (2 PowerPoint files) as you can see in the below images:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/two-presentations.png\" alt=\"Presentations-Object\" title=\"Presentations-Object\" width=\"256\" height=\"142\" class=\"size-full wp-image-4258\" \/><\/p>\n<p>But these presentations will be looking something like below &#8211; an Empty Presentations without any Slide in it.<\/p>\n<div id=\"attachment_4259\" style=\"width: 522px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" aria-describedby=\"caption-attachment-4259\" src=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/PowerPoint-Presentation.png\" alt=\"PowerPoint-Presentation-Object\" title=\"PowerPoint-Presentation-Object\" width=\"512\" height=\"461\" class=\"size-full wp-image-4259\" \/><p id=\"caption-attachment-4259\" class=\"wp-caption-text\">Power Point Presentation Object<\/p><\/div>\n<p>As you can see in the above image, there is no slide. Now let us see how to add a slide in a presentation created above.<br \/>\n<a name=\"excel-macro-to-add-new-slides\"><\/a><\/p>\n<h1>VBA code to add slides to PowerPoint Presentation<\/h1>\n<p>In the above example you had added two new presentations with no slide. As you already know, each presentation file may contain multiple slides in it. That means, a Presentatio Object holds a collection of Slides. This means&#8230;You can add slides to <strong>Slides collection<\/strong> using <strong>.Add<\/strong> method of Slides object (Collection of Slide).<br \/>\nRefer the Syntax of this method below<\/p>\n<h2>Syntax of .Add Method<\/h2>\n<p>.Add method belongs to <strong>Slides<\/strong> Object.<br \/>\n[highlight color=&#8221;yellow&#8221;]MyPresentation1.Slides.Add &lt;Index Number&gt; , &lt;Layout of the slide&gt;[\/highlight]<\/p>\n<h2>Where:<\/h2>\n<p><strong>Index Number: <\/strong><br \/>\n<i>Slides<\/i> is basically a collection of all Slide Object, a Presentation has it. Therefore to add a slide in Slides collection, you need to pass the index number which tells the position of the new slide in Slides collection. In simple terms, this indicates the position of your Slide in your PowerPoint Presentation.<br \/>\n<strong>For example:<\/strong> If you pass Index number as 3 then new slide will be added at 3rd position, no matter how many more slides are there. But if total number of slides are less than 2 and you passed index as 3 then it will throw an error.<\/p>\n<p><strong>Layout of the slide: <\/strong><br \/>\nThis basically tells the type of Layout you want for your new slide. There is a list of around more than 20 layout type which you can use it for Power Point 2007. You can pass the exact VBA name of a layout or just an integer number (depending on the version of the Office you have in your computer)<\/p>\n<pre><code class=\"language-vbnet\">\r\nSub Add_slide_to_PowerPoint()\r\n'Define one variable of Object Type to hold the Application Object\r\n\tDim objNewPowerPoint As PowerPoint.Application\r\n\tDim MyPresentation As Presentation\r\n\tDim pSlides As Slides\r\n\tOn Error GoTo err\r\n'Create an Object for PowerPoint Application\r\n\tSet objNewPowerPoint = New PowerPoint.Application\r\n\t\r\n'Make this Application Object Visible\r\n\tobjNewPowerPoint.Visible = True\r\n'Open your presentation and assign it to MyPresentation Object\r\n\tSet MyPresentation = objNewPowerPoint.Presentations.Open(&amp;quot;C:\\Users\\vmishra\\Desktop\\PPT-Slides.pptx&amp;quot;)\r\n'Assign the Collection of Slide Objects to an Object Variable\r\n\tSet pSlides = MyPresentation.Slides\r\n' Note: pSlides Object has all the slides in that presentation\r\n' Below statement will add a new slide to the collection\r\n' at the given location, e.g. at 3rd position.\r\n' SlideLayout is given as Blank slide layout\r\n\tpSlides.Add 3, ppLayoutBlank\r\n'save and close the presentation\r\n\tMyPresentation.Save\r\n\tMyPresentation.Close\r\n'release the memory from all the objects\r\n\tSet MyPresentation = Nothing\r\n\tSet pSlides = Nothing\r\n'Finally quit the Power Point application\r\n\tobjNewPowerPoint.Quit\r\n\tExit Sub\r\n\terr:\r\n'if any Error occurred, display the error code and description\r\n\tMsgBox err.Number &amp;amp; &amp;quot;: &amp;quot; &amp;amp; err.Description\r\nEnd Sub\r\n<\/code><\/pre>\n<p><a name=\"excel-macro-to-save-presentation\"><\/a><\/p>\n<h1>Save &#038; Close PowerPoint Through Excel VBA<\/h1>\n<p>Let&#8217;s have a look &#8211; on how to save and close a power point presentation using Excel VBA.<br \/>\n<strong>.Save<\/strong> and <strong>.Close<\/strong> is the keywords to save and close a presentation respectively. These methods belongs to Presentation Object.<\/p>\n<pre><code class=\"language-vbnet\">\r\n\tDim objNewPowerPoint As PowerPoint.Application\r\n\tDim MyPresentation As Presentation\r\n\t\r\n\tSet objNewPowerPoint = New PowerPoint.Application\r\n\t'Open your presentation and assign it to MyPresentation Object\r\n\tSet MyPresentation = objNewPowerPoint.Presentations.Open(&amp;quot;C:\\Users\\...\\Desktop\\PPT-Slides.pptx&amp;quot;)\r\n\t'Save the presentation \r\n\tMyPresentation.Save\r\n\t\r\n\t'Close the presentation\r\n\tMyPresentation.Close\r\n<\/code><\/pre>\n<p>In case you want to save your presentation with a different name or at different location then you can use <strong>.SaveAs<\/strong> method. The only difference in both these methods is &#8211; For <strong>.Save<\/strong> you do not need to provide file path but for <strong>.SaveAs<\/strong> it is mandatory to provide the file path. Refer below code.<\/p>\n<pre><code class=\"language-vbnet\">\r\n\tDim objNewPowerPoint As PowerPoint.Application\r\n\tDim MyPresentation As Presentation\r\n\t\r\n\tSet objNewPowerPoint = New PowerPoint.Application\r\n\t'Open your presentation and assign it to MyPresentation Object\r\n\tSet MyPresentation = objNewPowerPoint.Presentations.Open(&amp;quot;C:\\Users\\...\\Desktop\\PPT-Slides.pptx&amp;quot;)\r\n\t\r\n\t'SaveAs the presentation at different location with different name\r\n\tMyPresentation.SaveAs Filename:=desktopURL &amp;amp; &amp;quot;C:\\..\\..\\Desktop\\PPT-Slides-New.pptx&amp;quot;\r\n<\/code><\/pre>\n<div class=\"alert alert-info\">\n<h2>What did we learn so far?<\/h2>\n<p>1. How to create Power Point Application , Presentations and Slides Objects<br \/>\n2. How to create new Power Point Presentations<br \/>\n3. How to add slides to power point presentation<br \/>\n4. How to Save and Close Presentations in Excel VBA\n<\/p><\/div>\n<p><a name=\"excel-macro-to-create-new-powerpoint-presentation\"><\/a><\/p>\n<h1>VBA to Create a New Power Point Presentation<\/h1>\n<p>As I have explained above, I will club all the lines of code with some more statements together and form a single code which will do the following :<\/p>\n<p>1. Create 2 New Power Point File<br \/>\n2. Add 5 slides in one presentation and 3 in second one.<br \/>\n3. Save these power point presentation files on your desktop<\/p>\n<pre><code class=\"language-vbnet\">\r\nOption Explicit\r\nSub Add_Two_Presentations()\r\n'Define one variable of Object Type to hold the Application Object\r\nDim objNewPowerPoint As Object\r\nDim MyPresentation1 As Object\r\nDim MyPresentation2 As Object\r\nDim p1Slides As Object\r\nDim p2Slides As Object\r\nDim iSlide As Integer\r\nDim desktopURL\r\nOn Error GoTo err\r\n'Create an Object for PowerPoint Application\r\nSet objNewPowerPoint = CreateObject(&amp;quot;PowerPoint.Application&amp;quot;)\r\n'Make this Application Object Visible\r\nobjNewPowerPoint.Visible = True\r\n'Create 2 presentations from that Application Object\r\nSet MyPresentation1 = objNewPowerPoint.Presentations.Add\r\nSet MyPresentation2 = objNewPowerPoint.Presentations.Add\r\n'Assign the Collection of Slide Objects to an Object Variable\r\nSet p1Slides = MyPresentation1.Slides\r\nSet p2Slides = MyPresentation2.Slides\r\n\r\n'Now add 5 slides in first presentation and 3 in second one\r\nFor iSlide = 1 To 5\r\n    p1Slides.Add iSlide, ppLayoutCustom\r\n    'this will add only 3 slides to the second ppt\r\n    If iSlide &amp;lt;= 3 Then\r\n        p2Slides.Add iSlide, ppLayoutCustom\r\n    End If\r\nNext\r\n\r\n'get the desktop path\r\ndesktopURL = CreateObject(&amp;quot;WScript.Shell&amp;quot;).specialfolders(&amp;quot;Desktop&amp;quot;)\r\n'save both the ppts on the desktop\r\nMyPresentation1.SaveAs Filename:=desktopURL &amp;amp; &amp;quot;\\ppt1.pptx&amp;quot;\r\nMyPresentation2.SaveAs Filename:=desktopURL &amp;amp; &amp;quot;\\ppt2.pptx&amp;quot;\r\n\r\n'close both the presentations\r\nMyPresentation1.Close\r\nMyPresentation2.Close\r\n\r\n'release the memory from all the objects\r\nSet MyPresentation1 = Nothing\r\nSet MyPresentation2 = Nothing\r\nSet p1Slides = Nothing\r\nSet p2Slides = Nothing\r\n'Finally quit the Power Point application\r\nobjNewPowerPoint.Quit\r\nExit Sub\r\nerr:\r\n'if any Error occurred, display the error code and description\r\nMsgBox err.Number &amp;amp; &amp;quot;: &amp;quot; &amp;amp; err.Description\r\nEnd Sub\r\n<\/code><\/pre>\n<p>&nbsp;<br \/>\nYou have learnt above, how to create a new Powerpoint presentation with multiple slides in it, save and close it. Now I will teach you how to open an existing Power Point file using Excel VBA<br \/>\n<a name=\"excel-macro-to-open-powerpoint-presentation\"><\/a><\/p>\n<h1>Excel VBA to open PowerPoint Presentation File<\/h1>\n<p>First you need to create a PowerPoint Application object which will actually hold your opened presentation file. If you do not have a valid Power Point Application object then you can not open your presentation file directly. <\/p>\n<p>To open a presentation you can use the below statement:<\/p>\n<pre><code class=\"language-vbnet\">\r\nobjNewPowerPoint.Presentations.Open(&amp;quot;filepath&amp;quot;)\r\n<\/code><\/pre>\n<h2>Where :<\/h2>\n<p><strong>objNewPowerPoint &#8211;<\/strong> is your defined Power Point Application Object<br \/>\n<strong>FilePath &#8211; <\/strong>This is the complete path of the file with file name with file extension<\/p>\n<p>Above statement opens a presentation file which is a Presentation Object. Therefore we should assign this to a unique object so that at any point of program we can refer this presentation uniquely.<\/p>\n<pre><code class=\"language-vbnet\">\r\nDim MyPresentation3 as Object\r\nSet MyPresentation3 = objNewPowerPoint.Presentations.Open(&amp;quot;filepath&amp;quot;)\r\n<\/code><\/pre>\n<p>Now you can use <strong>MyPresentation3<\/strong> presentation object to add slides to it, delete, save, close etc. same as the above code.<\/p>\n<h1>Example:<\/h1>\n<p>Now let us create an example with everything we learnt so far. In this example, I am going to do the following:<\/p>\n<div class=\"alert alert-info\">\n<p>1. open an Existing power point presentation<br \/>\n2. Add a Slide at 3rd position (make sure that the file you choose, has, at least 2 slides other wise it will through as an exception as explained above)<br \/>\n3. Save and close the presentation<\/p>\n<\/div>\n<pre><code class=\"language-vbnet\">\r\n\r\nSub Open_an_existing_Presentations()\r\n'Define one variable of Object Type to hold the Application Object\r\nDim objNewPowerPoint As Object\r\nDim MyPresentation As Object\r\nDim pSlides As Object\r\n\r\nOn Error GoTo err\r\n'Create an Object for PowerPoint Application\r\nSet objNewPowerPoint = CreateObject(&amp;quot;PowerPoint.Application&amp;quot;)\r\n'Make this Application Object Visible\r\nobjNewPowerPoint.Visible = True\r\n'Open your presentation and assign it to MyPresentation Object\r\nSet MyPresentation = objNewPowerPoint.Presentations.Open(&amp;amp;lt;Comeplete path&amp;amp;gt;)\r\n'Assign the Collection of Slide Objects to an Object Variable\r\nSet pSlides = MyPresentation.Slides\r\n'Note: pSlides Object has all the slides in that presentation\r\n'Now add a new slide at 3rd position in the collection of slides pSlides\r\npSlides.Add 3, ppLayoutCustom\r\n'save and close the presentation\r\nMyPresentation.Save\r\nMyPresentation.Close\r\n'release the memory from all the objects\r\nSet MyPresentation = Nothing\r\nSet pSlides = Nothing\r\n'Finally quit the Power Point application\r\nobjNewPowerPoint.Quit\r\nExit Sub\r\nerr:\r\n'if any Error occurred, display the error code and description\r\nMsgBox err.Number &amp;amp; &amp;quot;: &amp;quot; &amp;amp; err.Description\r\nEnd Sub\r\n<\/code><\/pre>\n<p><a name=\"excel-macro-to-save-new-presentation\"><\/a><\/p>\n<div class=\"alert alert-warning\">\n<h2><i class=\"fa fa-lightbulb-o fa-2x\" aria-hidden=\"true\"><\/i> Important: Difference between Save and SaveAs<\/h2>\n<p>In the first example as well we saved one presentation. But in this example <strong>Save<\/strong> is different. If you notice in the first example we had used <strong>SaveAs<\/strong> because it was a new file and we have to give a valid path and name to save it but in this example this file is already saved in a particular location with a name from where you have opened it. <\/p>\n<p>Therefore in this case you can simply run the <strong>Save<\/strong> command which will save the changes you made in that presentation. But if you still want to save this as a different file name or location you can go ahead with <strong>SaveAs<\/strong> command. <strong>Save As<\/strong> is same as the save as command in any file.<\/p>\n<\/div>\n<p><a name=\"excel-macro-to-delete-slides-from-a-presentation\"><\/a><\/p>\n<h1>VBA Code to delete slide from PowerPoint Presentation<\/h1>\n<p><strong><em>.Delete<\/em><\/strong> method is used to delete a single slide from Slide collection. This method belongs to a single Slide Object. You must identify a single slide item from Slides collection before deleting it.<\/p>\n<h2>Syntax:<\/h2>\n<p><strong>pSlides(slideNumber).Delete<\/strong><\/p>\n<h2>OR<\/h2>\n<p><strong>pSlides.Item(slideNumber).Delete<\/strong><\/p>\n<h2>Where:<\/h2>\n<p><strong>pSlides :<\/strong> Variable of Slides type where Slide collection of the presentation stored from which slides has to be deleted<\/p>\n<p><strong>slideNumber :<\/strong> As the name says.. Slide number which you want to delete. Like for 1st Slide &#8211; 1, for second &#8211; 2 and so on..<\/p>\n<div class=\"alert alert-warning\">\n<h2><i class=\"fa fa-lightbulb-o fa-2x\" aria-hidden=\"true\"><\/i> Important Point<\/h2>\n<p>While adding a new slide, we add it in the collection (Slides), therefore <strong><em>.Add<\/em><\/strong> method belongs to Slides collection. But, while deleting a slide, we delete individual slides from the collection, therefore <strong><em>.Delete<\/em><\/strong> is a method of Slide object -><strong> (Slides.Item(i))<\/strong><\/p>\n<\/div>\n<pre><code class=\"language-vbnet\">\r\nSub Delete_a_slide_from_presentation()\r\n'Define one variable of Object Type to hold the Application Object\r\n\tDim objNewPowerPoint As PowerPoint.Application\r\n\tDim MyPresentation As Presentation\r\n\tDim pSlides As Slides\r\n\t\r\n\tOn Error GoTo err\r\n'Create an Object for PowerPoint Application\r\n\tSet objNewPowerPoint = New PowerPoint.Application\r\n\t\r\n'Make this Application Object Visible\r\n\tobjNewPowerPoint.Visible = True\r\n'Open your presentation and assign it to MyPresentation Object\r\n\tSet MyPresentation = objNewPowerPoint.Presentations.Open(&amp;quot;PPT-Slides.pptx&amp;quot;)\r\n'Assign the Collection of Slide Objects to an Object Variable\r\n\tSet pSlides = MyPresentation.Slides\r\n' Note: pSlides Object has all the slides in that presentation\r\n' Below statement will delete the second slide from the Slides Collection\r\n\tpSlides.Item(2).Delete\r\n'save and close the presentation\r\n\tMyPresentation.Save\r\n\tMyPresentation.Close\r\n'release the memory from all the objects\r\n\tSet MyPresentation = Nothing\r\n\tSet pSlides = Nothing\r\n'Finally quit the Power Point application\r\n\tobjNewPowerPoint.Quit\r\n\tExit Sub\r\n\terr:\r\n'if any Error occurred, display the error code and description\r\n\tMsgBox err.Number &amp;amp; &amp;quot;: &amp;quot; &amp;amp; err.Description\r\nEnd Sub\r\n\r\n<\/code><\/pre>\n<div class=\"alert alert-info\">\n<h1>About the Next Article&#8230;<\/h1>\n<p>In this article I will cover the following:<br \/>\n1. Create Power Point Presentations by creating the Object using <strong>CreateObject<\/strong> keyword.<br \/>\n2. Some Useful and practical Examples<\/p>\n<p><strong><em>FREE Download : <\/em><\/strong>In addition to this, I have created a simple yet <strong><em>powerful Excel VBA tool <\/em><\/strong>to consolidate Slides from different PowerPoint presentations in a particular folder.<br \/>\nI will not talk more about it here.\n<\/div>\n<span class=\"et_bloom_bottom_trigger\"><\/span>","protected":false},"excerpt":{"rendered":"<p>[fusion_text] ear Friends, First of all, I apologize for not responding to many of your questions around dealing with PowerPoint presentations through Excel Macro. Many of you have sent me so many questions around this topic. Questions, which were, mostly, asked were like &#8211; Sample List of Questions&#8230; &nbsp; VBA code to create a presentation [&hellip;]<\/p>\n","protected":false},"author":45,"featured_media":14218,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","rop_custom_images_group":[],"rop_custom_messages_group":[],"rop_publish_now":"initial","rop_publish_now_accounts":{"facebook_10221221723514640_204908552914904":"","twitter_aTo1MTIwNTUyMDQ7_512055204":""},"rop_publish_now_history":[],"rop_publish_now_status":"pending","footnotes":""},"categories":[1675],"tags":[],"class_list":["post-4238","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel-macro-for-beginners"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v23.5 (Yoast SEO v23.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Complete VBA tutorial to interact with Power point Presentations - Part - 1<\/title>\n<meta name=\"description\" content=\"VBA to create a new presentation. Add Slides to a presentation through Excel VBA. Save &amp; Close presentation using VBA. Delete slide from Presentation in VBA\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Complete VBA tutorial to interact with Power point Presentations - Part - 1\" \/>\n<meta property=\"og:description\" content=\"VBA to create a new presentation. Add Slides to a presentation through Excel VBA. Save &amp; Close presentation using VBA. Delete slide from Presentation in VBA\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"Let&#039;s excel in Excel\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:author\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-19T13:26:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-12T11:42:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png\" \/>\n\t<meta property=\"og:image:width\" content=\"815\" \/>\n\t<meta property=\"og:image:height\" content=\"519\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vishwamitra Mishra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/www.twitter.com\/learnexcelmacro\" \/>\n<meta name=\"twitter:site\" content=\"@learnexcelmacro\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vishwamitra Mishra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/\"},\"author\":{\"name\":\"Vishwamitra Mishra\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"headline\":\"Complete VBA tutorial to interact with Power point Presentations &#8211; Part &#8211; 1\",\"datePublished\":\"2014-09-19T13:26:25+00:00\",\"dateModified\":\"2022-08-12T11:42:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/\"},\"wordCount\":1697,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"image\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png\",\"articleSection\":[\"Excel Macro Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/\",\"name\":\"Complete VBA tutorial to interact with Power point Presentations - Part - 1\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png\",\"datePublished\":\"2014-09-19T13:26:25+00:00\",\"dateModified\":\"2022-08-12T11:42:47+00:00\",\"description\":\"VBA to create a new presentation. Add Slides to a presentation through Excel VBA. Save & Close presentation using VBA. Delete slide from Presentation in VBA\",\"breadcrumb\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#primaryimage\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png\",\"width\":815,\"height\":519},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/vmlogger.com\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Macro Tutorial\",\"item\":\"https:\/\/vmlogger.com\/excel\/excel-macro-for-beginners\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Complete VBA tutorial to interact with Power point Presentations &#8211; Part &#8211; 1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\",\"url\":\"https:\/\/vmlogger.com\/excel\/\",\"name\":\"Let&#039;s excel in Excel\",\"description\":\"Let&#039;s share knowledge\",\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/vmlogger.com\/excel\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\",\"name\":\"Vishwamitra Mishra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"width\":528,\"height\":560,\"caption\":\"Vishwamitra Mishra\"},\"logo\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\"},\"description\":\"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore &amp; currently working as a Technical Lead having over 7 years of experience.\",\"sameAs\":[\"http:\/\/www.learnexcelmacro.com\",\"http:\/\/www.facebook.com\/vmlogger\",\"https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro\",\"https:\/\/www.youtube.com\/c\/VMLogger\"],\"url\":\"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Complete VBA tutorial to interact with Power point Presentations - Part - 1","description":"VBA to create a new presentation. Add Slides to a presentation through Excel VBA. Save & Close presentation using VBA. Delete slide from Presentation in VBA","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/","og_locale":"en_US","og_type":"article","og_title":"Complete VBA tutorial to interact with Power point Presentations - Part - 1","og_description":"VBA to create a new presentation. Add Slides to a presentation through Excel VBA. Save & Close presentation using VBA. Delete slide from Presentation in VBA","og_url":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/","og_site_name":"Let&#039;s excel in Excel","article_publisher":"http:\/\/www.facebook.com\/vmlogger","article_author":"http:\/\/www.facebook.com\/vmlogger","article_published_time":"2014-09-19T13:26:25+00:00","article_modified_time":"2022-08-12T11:42:47+00:00","og_image":[{"width":815,"height":519,"url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png","type":"image\/png"}],"author":"Vishwamitra Mishra","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/www.twitter.com\/learnexcelmacro","twitter_site":"@learnexcelmacro","twitter_misc":{"Written by":"Vishwamitra Mishra","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#article","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/"},"author":{"name":"Vishwamitra Mishra","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"headline":"Complete VBA tutorial to interact with Power point Presentations &#8211; Part &#8211; 1","datePublished":"2014-09-19T13:26:25+00:00","dateModified":"2022-08-12T11:42:47+00:00","mainEntityOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/"},"wordCount":1697,"commentCount":6,"publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"image":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png","articleSection":["Excel Macro Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/","url":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/","name":"Complete VBA tutorial to interact with Power point Presentations - Part - 1","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#primaryimage"},"image":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png","datePublished":"2014-09-19T13:26:25+00:00","dateModified":"2022-08-12T11:42:47+00:00","description":"VBA to create a new presentation. Add Slides to a presentation through Excel VBA. Save & Close presentation using VBA. Delete slide from Presentation in VBA","breadcrumb":{"@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#primaryimage","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2014\/09\/VBA-to-powerpoint-tutorial.png","width":815,"height":519},{"@type":"BreadcrumbList","@id":"https:\/\/vmlogger.com\/excel\/2014\/09\/power-point-using-excel-vba-tutorial-part-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vmlogger.com\/excel\/"},{"@type":"ListItem","position":2,"name":"Excel Macro Tutorial","item":"https:\/\/vmlogger.com\/excel\/excel-macro-for-beginners\/"},{"@type":"ListItem","position":3,"name":"Complete VBA tutorial to interact with Power point Presentations &#8211; Part &#8211; 1"}]},{"@type":"WebSite","@id":"https:\/\/vmlogger.com\/excel\/#website","url":"https:\/\/vmlogger.com\/excel\/","name":"Let&#039;s excel in Excel","description":"Let&#039;s share knowledge","publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vmlogger.com\/excel\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5","name":"Vishwamitra Mishra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","width":528,"height":560,"caption":"Vishwamitra Mishra"},"logo":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/"},"description":"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore &amp; currently working as a Technical Lead having over 7 years of experience.","sameAs":["http:\/\/www.learnexcelmacro.com","http:\/\/www.facebook.com\/vmlogger","https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro","https:\/\/www.youtube.com\/c\/VMLogger"],"url":"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/"}]}},"_links":{"self":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/4238"}],"collection":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/comments?post=4238"}],"version-history":[{"count":0,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/4238\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media\/14218"}],"wp:attachment":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media?parent=4238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/categories?post=4238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/tags?post=4238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}