macro to copy chart from excel to powerpoint

Anonymous
2012-12-06T11:21:19+00:00

is there a way i can get a macro to copy a chart from excel into power point? I know how to do it for tables within the actual sheet, but cannot seem to get the chart to copy as i cannot use cell ranges.

Thanks

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

50 answers

Sort by: Most helpful
  1. Anonymous
    2013-06-24T13:09:59+00:00

    This code works great!! I was wondering if there was a way to paste as a link? My attempts have been in vain thus far. 

    PPSlide.Shapes.PasteSpecial(Link:=True).Select

    Hi,

    To paste a linked picture that will NOT be editable as a chart within PowerPoint, but will be updated when the chart is changed in your ALREADY SAVED Excel file, you can use:

    Sub PastingLinkedPictures()

    Dim shp As Shape

    Dim sld As Slide

    Set sld = ActiveWindow.View.Slide

    Set shp = sld.Shapes(1) 'this would be whatever placeholder you want the chart to appear

    ActiveWindow.View.PasteSpecial DataType:=ppPasteMetafilePicture, Link:=msoTrue

    ActiveWindow.Selection.Cut

    shp.Select

    ActiveWindow.View.Paste

    End Sub

    The extra lines of code are there to move the pasted linked picture into a specific placeholder.

    If you want to paste as a linked chart, I think you just need to paste (ActiveWindow.View.Paste).

    Hope that helps.

    Cheers

    Rich

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-06-17T14:40:40+00:00

    This code works great!! I was wondering if there was a way to paste as a link? My attempts have been in vain thus far. 

    PPSlide.Shapes.PasteSpecial(Link:=True).Select

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2012-12-06T15:38:20+00:00

    They are simply called Chart 1, Chart 2 etc.

    I am trying to follow what is happening in your macro but i cannot work it out. I can get it to add one chart but not multiple. Also i still cannot get the template to work. Sorry

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-12-06T13:46:07+00:00

    Here’s how to use a template:

        Dim strPptTemplatePath As String


    strPptTemplatePath = "C:\temp\My PowerPoint Template.potx"

    'Get the PowerPoint Application object:

    Set ppt = CreateObject("PowerPoint.Application")

    ppt.Visible = msoTrue

    Set pptPres = ppt.Presentations**.Open(strPptTemplatePath, untitled:=msoTrue)**

    Yes, you can make charts copy into a certain part of the slide, but not like in Word.

    There are two ways to do this.  Either you just paste the charts on to the slide and then reposition and re-size in VBA, or you set up / use a Custom Layout in your template – this would be my preference.

    The code as is finds a Custom Layout named “Title and Content”.  That should have a Placeholder for objects (as well as a Title placeholder).

    Then the code looks through all the placeholders on the new slide to find the Placeholder for objects.  If you have more than one Placeholder for objects, you’d need to do a test to see if the position is correct, for example:

    'Find the right placeholder to paste into:

    For Each pptShp In pptSld.Shapes.Placeholders

    If pptShp.PlaceholderFormat.Type = ppPlaceholderObject Then

    If pptShp.Left = 50 Then Exit For

      End If

    Next pptShp

    Do you need to put specific charts in a specific order of slides?  In which case, you’ll need to give me some examples of chart names (as shown on thethe right of the Chart Tools > Layout tab when your chart is selected), and where you want them to be pasted.

    Cheers

    Rich

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2012-12-06T13:25:09+00:00

    Thats great. Thanks.

    1. Is there a way to copy the charts into a template form instead of a new power point presentation
    2. Can i reference the charts so they copy into a certain part of the form? When copying to word i was told to use bookmarks to show where to paste the information

    Was this answer helpful?

    0 comments No comments