Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Control PPt from xl (2007)

    Hi. I'm trying to automate PowerPoint from Excel:
    Dim myPPoint As PowerPoint.Application
    Dim myPresent As PowerPoint.Presentation
    Dim mySlide As PowerPoint.Slide

    Set myPPoint = CreateObject("PowerPoint.Application")
    With myPPoint
    .Visible = True
    Set myPresent = .Presentations.Add
    Set mySlide = myPresent.Slides.AddSlide(1, ppLayoutBlank)
    End With
    Excel gives a Type Mismatch error for the penultimate line (using AddSlide). I tried replacing 'ppLayoutBlank' with the number 2 but no luck.
    How can I tell PPt to add a new (blank) slide? Thanks, Andy.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Control PPt from xl (2007)

    The second argument of AddSlide must be a CustomLayout object, not a constant as for the Slides.Add method used in previous versions of PowerPoint.
    So you'll have to create a CustomLayout first. I don't have 2007, so I cannot test, but you probably need to do something like this:

    Dim myLayout As PowerPoint.CustomLayout
    Set myLayout = myPresent.SlideMaster.CustomLayouts.Add
    Set mySlide = myPresent.Slides.AddSlide(1, myLayout)

Posting Permissions

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