Macro to copy multiple Excel ranges and paste on same slide in PowerPoint

davidb88

Board Regular
Joined
Sep 23, 2013
Messages
76
I have a number of ranges in Excel that I'd like to copy and be able to paste into the same slide in an already created PPT presentation. With the below code that I've put together, for some reason only the first range is getting pasted into the slide and the second is either not pasting or getting deleted immediately after getting pasted into the slide. What am I doing wrong? Or is there maybe a better approach to copying multiple different ranges and pasting them into the same slide as separate pictures? Thanks in advance!

Code:
Sheets("Exec Summary").Activate
 Range("E4:L20").Select
    Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture


Set PowerPointApp = GetObject(class:="PowerPoint.Application")
Set myPresentation = PowerPointApp.ActivePresentation


For p = myPresentation.slides(7).Shapes.Count To 1 Step -1
    Set ppShape = myPresentation.slides(7).Shapes(p)
    If ppShape.Type = msoPicture Then ppShape.Delete
Next


With myPresentation.slides(7)
    .Shapes.Paste
    With .Shapes(.Shapes.Count)
        .Left = 100
        .Top = 125
        .Height = 325
        .Width = 500
    End With
End With

Sheets("Exec Summary").Activate
 Range("M20:P20").Select
    Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

With myPresentation.slides(7)
    .Shapes.Paste
    With .Shapes(.Shapes.Count)
        .Left = 100
        .Top = 525
        .Height = 325
        .Width = 500
    End With
End With
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top