Consulting

Results 1 to 4 of 4

Thread: Inserting new slide in PP from Excel

  1. #1
    VBAX Newbie
    Joined
    Apr 2005
    Posts
    3
    Location

    Inserting new slide in PP from Excel

    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

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    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...

  3. #3
    Knowledge Base Approver VBAX Expert brettdj's Avatar
    Joined
    May 2004
    Location
    Melbourne
    Posts
    649
    Location
    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

  4. #4
    VBAX Newbie
    Joined
    Apr 2005
    Posts
    3
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •