{"id":7522,"date":"2021-11-24T10:04:52","date_gmt":"2021-11-24T10:04:52","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=7522"},"modified":"2021-11-24T10:05:15","modified_gmt":"2021-11-24T10:05:15","slug":"powerpoint-vba-select-slide","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/powerpoint-vba-select-slide\/30096.html","title":{"rendered":"PowerPoint VBA Select Slide"},"content":{"rendered":"<p>My goal is to create ppt via VBA. I have already the template in my desktop that i need to use. This part of the code is ok.<\/p>\n<p>However I did not find how to select slides in the ppt. I try many ways and i get &#8220;ActiveX component can&#8217;t create object&#8221; error 429.<\/p>\n<p>If someone could help me.<\/p>\n<p>&nbsp;<\/p>\n<pre>Option Explicit\r\n \r\nSub CreatePowerPoint()\r\n \r\nDim mySlide As PowerPoint.Slide\r\nDim myShapeRange As PowerPoint.Shape\r\nDim oPA As PowerPoint.Application\r\nDim oPP As PowerPoint.Presentation\r\nDim strTemplate As String\r\nDim rng As Range\r\n \r\nstrTemplate = \"C:\\Users\\290866\\Desktop\\vba\\PPT\\Template.potx\"\r\n \r\nSet oPA = New PowerPoint.Application\r\noPA.Visible = msoTrue\r\noPA.Presentations.Open strTemplate, untitled:=msoTrue\r\n \r\nIf Not mySlide Is Nothing Then Set mySlide = Nothing\r\nIf Not oPP Is Nothing Then Set oPP = Nothing\r\nIf Not oPA Is Nothing Then Set oPA = Nothing\r\n \r\n \r\nErr_PPT:\r\nIf Err &lt;&gt; 0 Then\r\nMsgBox Err.Description\r\nErr.Clear\r\nResume Next\r\nEnd If\r\n \r\nSet rng = ThisWorkbook.Sheets(\"Credit Recommendation\").Range(\"B2:N59\")\r\n \r\nset mySlide = ActivePresentation.Slides(1)\r\n  rng.Copy\r\nmySlide.Shapes.PasteSpecial (ppPasteBitmap)\r\n  Set myShapeRange = mySlide.Shapes(mySlide.Shapes.Count)\r\nmyShapeRange.LockAspectRatio = msoFalse\r\n      myShapeRange.Left = 20\r\n      myShapeRange.Top = 80\r\n      myShapeRange.Height = 400\r\n myShapeRange.Width = 680\r\n  Application.CutCopyMode = False\r\n \r\n \r\nEnd Sub<\/pre>\n<p>Thank you<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":1},"question-category":[55],"question_tags":[],"class_list":["post-7522","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/7522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=7522"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=7522"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=7522"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=7522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}