locked
Copying a chart from Excel to Powerpoint RRS feed

  • Question

  • I would like to copy a graph from Excel to Powerpoint. I would like to then be able to double click the graph in Powerpoint and be able to edit the data so the graph changes. I understand that it needs to be copied as an OLEObject.

    My code so far is below but it only copies the graph as a picture. 

    xlApp.ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture        
     ppPres.Slides(Slideloop).Shapes.Paste.Select

    I assume I need to change the .CopyPicture to something else.

    Can you help?

     

    Friday, April 23, 2010 12:56 PM

Answers

  • Try,

     

    Sub CopyChartPPT()

        Dim objPPT As Object
        Dim objPres As Object
       
        Set objPPT = GetObject(, "Powerpoint.application")
        Set objPres = objPPT.activepresentation
       
        ActiveSheet.ChartObjects(1).Copy
        objPres.slides(1).Shapes.Paste
       
        Set objPres = Nothing
        Set objPPT = Nothing
       
    End Sub


    Cheers   www.andypope.info
    • Marked as answer by Gazza101 Friday, April 23, 2010 3:32 PM
    Friday, April 23, 2010 1:04 PM

All replies

  • Try,

     

    Sub CopyChartPPT()

        Dim objPPT As Object
        Dim objPres As Object
       
        Set objPPT = GetObject(, "Powerpoint.application")
        Set objPres = objPPT.activepresentation
       
        ActiveSheet.ChartObjects(1).Copy
        objPres.slides(1).Shapes.Paste
       
        Set objPres = Nothing
        Set objPPT = Nothing
       
    End Sub


    Cheers   www.andypope.info
    • Marked as answer by Gazza101 Friday, April 23, 2010 3:32 PM
    Friday, April 23, 2010 1:04 PM
  • Nice one.

    Thanks again.

    • Proposed as answer by AvivExpert Friday, April 23, 2010 4:43 PM
    Friday, April 23, 2010 3:31 PM
  • Consider using EzPaste-xl2anywhere (www.EzPaste.net)

     

    Good luck!

    Friday, April 23, 2010 4:44 PM