0
votes

I have the following code:

Sub Export_Allcahrts_ppt()
  Dim mypowerpoint As PowerPoint.Application
  Dim mypowerpoint_pres As PowerPoint.Presentation
  Dim myslide As PowerPoint.Slide
  Dim mychart As ChartObject

  Set mypowerpoint = New PowerPoint.Application
  mypowerpoint.Visible = msoTrue
  Set mypowerpoint_pres = mypowerpoint.Presentations.Add
  Set myslide = mypowerpoint_pres.Slides.Add(1, ppLayoutBlank)
  For Each mychart In Sheet1.ChartObjects
    mychart.Copy
    myslide.Shapes.PasteSpecial ppPasteBitmap
    With myslide.Shapes(myslide.Shapes.Count)
      .Top = 100
      .Height = 200
      .Left = 30
    End With
  Next
End Sub

How to select specific charts like chart 1 in sheet 1, chart 2 in sheet 2 in excel and paste them on a single slide in powerpoint?

1
Hi...someone help to modify the above code where i can copy charts from different sheets and paste then on single slide in power point ...thankskalyan
You can select and copy charts in Excel by using their names. .charts("Chart1").copymooseman
i am looking to copy charts from different sheets in excel and paste on single slide in power point.kalyan
How are the charts named? Chart1, Chart2, Chart3?mooseman
charts had specific names like "Direct Sales texas","Direct Sales California"..so onkalyan

1 Answers

0
votes

This will iterate through all sheets in workbook, then just check for the charts you are looking for. If the charts are named like chart1 on sheet1, then.....

Set wb as activeworkbook
For Each sht In wb.Worksheets
  For Each cht In sht.ChartObjects
    'check for name of chart, if statements or a case select statement.
    if cht.name = "Chart" & sht.index then

        'Copy to PPT
    end if

  Next cht
Next sht