Vba to add another slide RRS feed

  • Question

  • I have the code below which converts the active worksheet selected range into an active powerpoint slide. Is there a way I can add a second worksheet and its selected range to the active powerpoint presentation on a second slide:

    Sub macro_PPT()
    Dim PPApp As PowerPoint.Application
    Dim PPPres As PowerPoint.Presentation
    Dim PPSlide As PowerPoint.Slide
    Dim rng As Range
    ' Make sure a range is selected
        ' Reference existing instance of PowerPoint
    On Error Resume Next
        Set PPApp = GetObject(, "Powerpoint.Application")
            On Error GoTo 0
        If PPApp Is Nothing Then
            Set PPApp = CreateObject("Powerpoint.Application")
            PPApp.Visible = msoCTrue
            Set PPPres = PPApp.Presentations.Open("C:\Users\v562147\Desktop\Presentation Template.pptx")
            Set PPPres = PPApp.ActivePresentation
        End If

        ' Reference active presentation
        Set PPPres = PPApp.ActivePresentation
        PPApp.ActiveWindow.ViewType = ppViewSlide
        ' Reference active slide
        Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
        ' Copy the range as a piicture
        Selection.CopyPicture Appearance:=xlScreen, _

        ' Paste the range
        With PPApp.ActiveWindow.Selection.ShapeRange

    .Height = 600

    .Width = 450

    End With

        ' Align the pasted range
        PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
        PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

        ' Clean up
        Set PPSlide = Nothing
        Set PPPres = Nothing
        Set PPApp = Nothing

    Thursday, April 25, 2013 11:45 AM


All replies