Copy Excel charts as chart objects (not pictures) into Powerpoint

simpf

New Member
Joined
Mar 28, 2019
Messages
1
Hello,

I have a piece of code that I have used successfully many times going through different ranges in excel (mainly containing charts) and pasting theme into powerpoint as images.
Now I need to do the same but paste the charts as chart objects instead.

Any tips?

*

Sub open_ppt()


Dim ppApp As PowerPoint.Application
Dim pppres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide


Set ppApp = New PowerPoint.Application


ppApp.Visible = True
ppApp.Presentations.Open "C:\Users\XXX\Template.pptx"




Set pppres = ppApp.ActivePresentation


ppApp.Visible = True



' Using a specifik sheet (Master) containing information regarding the different ranges (named as image1, image2 etc).
For i = 1 To 8
Sheets("Master").Select
Range("b80").Select
ActiveCell.Offset(i, 0).Select
image = ActiveCell.Value
Range("c80").Select
ActiveCell.Offset(i, 0).Select
imageobj = ActiveCell.Value
Range("a80").Select
ActiveCell.Offset(i, 0).Select
Slide = ActiveCell.Value
Range("d80").Select
ActiveCell.Offset(i, 0).Select
pict_height = ActiveCell.Value
Range("e80").Select
ActiveCell.Offset(i, 0).Select
pict_width = ActiveCell.Value
Range("f80").Select
ActiveCell.Offset(i, 0).Select
pict_tb = ActiveCell.Value
Range("g80").Select
ActiveCell.Offset(i, 0).Select
pict_lr = ActiveCell.Value
Application.Goto Reference:=image
ActiveSheet.Range(image).CopyPicture xlScreen, xlPicture

ppApp.Visible = True

With pppres.Slides(Slide).Shapes.Paste
.Name = image
End With


With pppres.Slides(Slide).Shapes(image)
.Height = pict_height
.Width = pict_width
.Left = pict_lr
.Top = pict_tb
End With




Next i



End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try adopting the following code for your purposes...

Code:
    'copy the first chart object from the Master sheet
    Worksheets("Master").ChartObjects(1).Copy
    
    'paste chart object into the first slide of the presentation and set the properties
    With ppPres.Slides(1).Shapes.Paste
        .Left = 20
        .Top = 20
        .Width = 300
        .Height = 200
    End With

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

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