View Full Version : [SOLVED:] Inserting new slide in PP from Excel
LarryBud
04-22-2005, 10:59 AM
My objective is to create a PowerPoint presentation from Excel. I'm able to open the presentation and paste to existing slides, but am having trouble when I try to insert a new slide. Not having experience coding VBA in PowerPoint, I recorded the command to insert a slide, added the object to the front, and put it in my Excel VBA. Doesn't work. Does someone know what I am doing wrong?
Set PPApp = GetObject(, "PowerPoint.Application")
PPApp.Visible = True
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add _(Index:=6, Layout:=ppLayoutTitleOnly).SlideIndex
I get Run-time error '429' ActiveX component can't create object.
Thank you in advance for all assistance.
Larrybud
Norie
04-22-2005, 11:57 AM
GetObject will only work if PowerPoint is open.
Try CreateObject instead.
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Set PPApp = CreateObject("PowerPoint.Application")
PPApp.Visible = True
Set PPPres = PPApp.Presentations.Add
PPPres.Slides.Add Index:=PPPres.Slides.Count + 1, Layout:=ppLayoutTitleOnly
PPPres.Slides.Add Index:=PPPres.Slides.Count + 1, Layout:=ppLayoutTitleOnly
Note I added a reference to PowerPoint in Tools>References...
brettdj
04-22-2005, 07:01 PM
You might find this KB entry useful, it uses either an existing or new instance of PP to copy a graph or range from Excel either as a picture or linked object.
http://www.vbaexpress.com/kb/getarticle.php?kb_id=370
Cheers
Dave
LarryBud
04-25-2005, 07:28 AM
Thanks for your input guys and I apologize for not clearly stating my problem. Please let me restate it:
PowerPoint is open and a range has been pasted from Excel into PowerPoint onto an existing slide, actually slide #5.
At this point my Excel code determines that it is necessary to insert a new slide to continue copying and pasting from the same worksheet - the entire worksheet is too big to put on a single PP slide. Since slide #5 is not the last slide, #6 must be inserted.
The example code shows only adding a slide at the end. I suppose I could add a slide at the end, the move it to position #6, but I would rather just insert the blank slide.
This is code line where I get the error:
PPApp.ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add _(Index:=6, Layout:=ppLayoutTitleOnly).SlideIndex
I get Run-time error '429' ActiveX component can't create object.
Thanks again for your help.
Larry
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.