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: Newest
  1. Anonymous
    2013-12-15T11:25:46+00:00

    I tried it, and I get the pop up box to pick the chart - but then when I click the chart to export - it gives me an error.  Any idea what I might have done wrong?

    Hi,

    1. Did you select a chart, then run the macro?
    2. Did you correctly add the reference to the PPT object library?
    3. What error did it give?
    4. If you saw a Debug button, what line of code is highlighted when you click Debug?
    5. What version of Office are you using?

    Cheers

    Rich

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-12-14T14:07:52+00:00

    Thanks Rich!  I tried it, and I get the pop up box to pick the chart - but then when I click the chart to export - it gives me an error.  Any idea what I might have done wrong?

    Thanks!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-12-14T10:02:41+00:00

    This is awesome!  Is there a way to change this so that I can assign the Macro to a chart so that it only enters the chart you click into PPT?  Not all charts?

    Thanks so much!

    Something like this?

    Sub PushActiveChartToPPT()

    'Set reference to 'Microsoft PowerPoint 12.0 Object Library'

    'in the VBE via Tools > References...

    '

    Dim ppt As PowerPoint.Application

    Dim pptPres As PowerPoint.Presentation

    Dim pptSld As PowerPoint.Slide

    Dim pptCL As PowerPoint.CustomLayout

    Dim pptShp As PowerPoint.Shape

    If ActiveChart Is Nothing Then

    MsgBox "Please select a chart to copy to PowerPoint"

    Else

    'Get the PowerPoint Application object:

    Set ppt = CreateObject("PowerPoint.Application")

    ppt.Visible = msoTrue

    Set pptPres = ppt.Presentations.Add

    'Get a Custom Layout:

    For Each pptCL In pptPres.SlideMaster.CustomLayouts

    If pptCL.Name = "Title and Content" Then Exit For

    Next pptCL

    'Get a slide:

    Set pptSld = pptPres.Slides.AddSlide(pptPres.Slides.Count + 1, pptCL)

    pptSld.Select

    'Get a Placeholder on the slide:

    For Each pptShp In pptSld.Shapes.Placeholders

    If pptShp.PlaceholderFormat.Type = ppPlaceholderObject Then Exit For

    Next pptShp

    If pptShp Is Nothing Then Stop

    'Copy the ActiveChart:

    ActiveChart.ChartArea.Copy

             'Paste into Ppt:

    ppt.Activate

    pptShp.Select

    ppt.Windows(1).View.Paste

    End If

    End Sub

    Cheers

    Rich

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-12-13T21:33:35+00:00

    This is awesome!  Is there a way to change this so that I can assign the Macro to a chart so that it only enters the chart you click into PPT?  Not all charts?

    Thanks so much!

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2013-11-19T07:07:27+00:00

    This is great Rich! You are a genius!

    I ended up using this and I full tested it's limitations hehe

    With activeSlide.Shapes(2).TextFrame.TextRange

    'Get the text to the right of the chart:

    Set Rng = Range(Cells(cht.TopLeftCell.Row, "J"), Cells(cht.BottomRightCell.Row, "J"))

    For Each c In Rng    'loop through each cell in column J next to the chart...

    If c.Value <> "" And c.Value <> "Callouts:" Then

    .InsertAfter (c.Value & vbNewLine)

    End If

    Next c

    'Change the font size of the PlaceHolder:

    .Font.Size = 16

    End With

    Next cht

    The adding to the end of the ppt is exactly what I wanted because I want it to be flexible etc.

    Thanks again!

    Ian

    Was this answer helpful?

    0 comments No comments