Excel range copy/paste special, linked picture to existing PowerPoint Slide

LSUchamp06

New Member
Joined
Apr 16, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hey y'all,

I attempting to write a macro that will automate copying and pasting Excel ranges to PowerPoint as linked picture objects. Below is what I have thus far. Any help whatsoever would be appreciated.

Sub Excel_Range_to_PowerPoint()

'Declare PowerPoint Variables
Dim papp As PowerPoint.Application
Dim pppt As PowerPoint.Presentation
Dim psld As PowerPoint.Slide

'Open existing PowerPoint File
Set papp = New PowerPoint.Application
Set pppt = papp.Presentations.Open("c:\users\bsegura\desktop\P3 - ARH Financial Results - FINAL-copy.pptx")

'Select Excel range and copy, paste link, Microsoft Object
Sheets("Month vs PY-CONSOL").Select
Range("A9:R56").Select.CopyPicture Appearance:=xlScreen, Format:=xlPicture
psld.Shapes.PasteSpecial(DataType:=ppPastePNG).Select
With papp.ActiveWindow.Selection.SlideRange(2)
LockAspectRatio = msoFalse

.Height = 5.07
.Width = 5.13
.Top = 0.97
.Left = 0.05



End With

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Your code has a number of issues. Try the following code instead. Note, though, you'll need to make changes where specified.

VBA Code:
Sub Excel_Range_to_PowerPoint()

    'Declare PowerPoint variables
    Dim papp As PowerPoint.Application
    Dim pppt As PowerPoint.Presentation
    Dim psld As PowerPoint.Slide
   
    'Open existing PowerPoint file
    Set papp = New PowerPoint.Application
    Set pppt = papp.Presentations.Open("c:\users\bsegura\desktop\P3 - ARH Financial Results - FINAL-copy.pptx")
    Set psld = pppt.Slides(2) 'change the slide as desired
   
    'Copy Excel range as picture
    Sheets("Month vs PY-CONSOL").Range("A9:R56").CopyPicture Appearance:=xlScreen, Format:=xlPicture
   
    'Paste to PowerPoint
    psld.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile
   
    'Position picture (change the settings as desired)
    With papp.ActiveWindow.Selection.ShapeRange
        .LockAspectRatio = msoFalse
        .Left = 10
        .Top = 10
        .Width = 200
        .Height = 200
    End With

End Sub

Hope this helps!
 
Upvote 0
Your code has a number of issues. Try the following code instead. Note, though, you'll need to make changes where specified.

VBA Code:
Sub Excel_Range_to_PowerPoint()

    'Declare PowerPoint variables
    Dim papp As PowerPoint.Application
    Dim pppt As PowerPoint.Presentation
    Dim psld As PowerPoint.Slide
  
    'Open existing PowerPoint file
    Set papp = New PowerPoint.Application
    Set pppt = papp.Presentations.Open("c:\users\bsegura\desktop\P3 - ARH Financial Results - FINAL-copy.pptx")
    Set psld = pppt.Slides(2) 'change the slide as desired
  
    'Copy Excel range as picture
    Sheets("Month vs PY-CONSOL").Range("A9:R56").CopyPicture Appearance:=xlScreen, Format:=xlPicture
  
    'Paste to PowerPoint
    psld.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile
  
    'Position picture (change the settings as desired)
    With papp.ActiveWindow.Selection.ShapeRange
        .LockAspectRatio = msoFalse
        .Left = 10
        .Top = 10
        .Width = 200
        .Height = 200
    End With

End Sub

Hope this helps!
Thank you Domenic! It works!
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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