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
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,013
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:

Forum statistics

Threads
1,082,298
Messages
5,364,375
Members
400,793
Latest member
hamzayagiz

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top