{"id":4270,"date":"2015-07-12T14:04:22","date_gmt":"2015-07-12T14:04:22","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/wp\/?p=4270"},"modified":"2017-08-29T17:54:51","modified_gmt":"2017-08-29T17:54:51","slug":"interacting-with-powerpoint-slides-tutorial-part-2","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2015\/07\/interacting-with-powerpoint-slides-tutorial-part-2\/","title":{"rendered":"Complete VBA tutorial to interact with Power point Presentations – Part – 2 of 2"},"content":{"rendered":"
This is a continuation of my previous article<\/strong> <\/a> about Interaction with Power point Slides using Excel Macro. In my previous article we learn how to create a New Power Point Presentation using Excel Macro (by creating Power Point Object). <\/p>\n This article I planned to write due an incident took place at my work. Friday evening, clock is ticking to 5 PM..All set to go for the weekend… and then there was a request from my BOSS to do some copy paste work in bunch of Sales PPTs. There were around 20-30 PPTs, each of them having at least 5-6 Slides in it. Click on the below links to directly jump to that section…<\/p>\n <\/a><\/p>\n The reference which you need to add in your Excel Code is Microsoft Power Point (12, 13, 14,15) Object Library<\/strong> as shown in the below picture.<\/p>\n 1. Open your VBE Code Screen (by Pressing ALT+F11) \nNow since, reference is already added, you don’t need to create an Object for Power Point using CreateObject<\/strong> keywords like it is done in my previous article.<\/p>\n Now we can define a new variable of Power Presentation type <\/p>\n <\/a><\/p>\nBit of a Story about this Article:<\/h1>\n
\nMy Job was to consolidate all the slides in one new Power Point Presentation. In a chat with my Boss, I realized that this activity is more frequently done by him. Then I put some effort and wrote an Excel Macro to do his Job faster without any manual error. At the end of this article you will find a downloadable, it’s the same version which I created.
\nLater after building this little tool for him, I realized that I can use this code to make quick presentations out of any dynamically generated reports\/data in excel and believe me it was very useful.
\nHowever this was a bit of story.. let’s get back to the topic…<\/p>\nTopics covered in this Article<\/h1>\n
<\/i> What is the Power Point Application Object reference and How to add it<\/a><\/h2>\n
<\/i> Excel VBA code to navigate to a specific slide in PPT<\/a><\/h2>\n
<\/i> VBA Code to copy a slide from one Power Point to Another<\/a><\/h2>\n
<\/i> Few VBA Trick while working with Slides<\/a><\/h2>\n<\/div>\n<\/div>\n
What is the Power Point Application Object reference and How to add it <\/h1>\n
\n2. From VBE screen go to Tools –> References
\n3. On Clicking on “References” you will see following screen, where you can look for the relevant reference and add it by selecting it.
\n<\/p>\n\r\n Dim newPowerPoint As PowerPoint.Application\r\n Set newPowerPoint = New PowerPoint.Application\r\n<\/code><\/pre>\n
OR<\/h2>\n
\r\n Dim newPowerPoint As New PowerPoint.Application\r\n<\/code><\/pre>\n
How to traverse all the slides of a Power Point Presentation<\/h1>\n
\r\n\r\nFunction get_Slide_Count()\r\n Dim pPath As String\r\n Dim pCount As Integer\r\n Dim pPowerPoint As New PowerPoint.Application\r\n Dim pPresentation As PowerPoint.Presentation\r\n \r\n 'Full Path of your Power point presentation\r\n pPath = "......\\PPT-Tutorial.pptx" 'For example\r\n Set pPresentation = pPowerPoint.Presentations.Open(pPath)\r\n \r\n 'Get the total count of slides\r\n pCount = pPresentation.Slides.Count\r\n \r\n 'Display message with total count\r\n MsgBox "Total No# of Slides is: " & pCount\r\n\r\n pPresentation.Close 'Close the power point presentation\r\n pPowerPoint.Quit 'now quit the power point Application\r\n \r\n 'Set both the Object variables to Nothing\r\n Set pPresentation = Nothing\r\n Set pPowerPoint = Nothing\r\nEnd Function\r\n<\/code><\/pre>\n