• How to paste unlinked charts from Excel to PowerPoint using VBA

    Home » Forums » AskWoody support » Productivity software by function » Productivity software by function – other » How to paste unlinked charts from Excel to PowerPoint using VBA

    Author
    Topic
    #482355

    Hi everybody,

    As the subject states, I’m trying to paste an unlinked chart from Excel to power point (2010). I haven’t been able to do so, this is what I have up to now. I have accomplished to paste the charts but no pastespecial code allows me to keet an embed and unlinked chart. For some weird reason the chart is allways linked to the Excel where it comes from (unless I paste it as a picture or as an object, not what I need)… can anyone help me with this?

    Thanks!

    Regards!

    CODE:

    Dim pptApp As PowerPoint.Application
    Dim pptPres As PowerPoint.Presentation
    Dim pptSlide As PowerPoint.Slide
    Dim pptShape As PowerPoint.Shape

    Dim Template As Variant
    Template = Application.GetOpenFilename(“PowerPoint (*.pptx),*.pptx”, , “Please select Template “)

    Set pptApp = CreateObject(“PowerPoint.Application”)
    pptApp.Visible = msoTrue
    Set pptPres = pptApp.Presentations.Open(Template) ‘ create a new presentation

    ‘******************************************
    ‘pasting the chart

    Windows(name2).Activate
    ActiveWorkbook.Sheets(“Chart1”).Select ‘ copy an Excel chart item
    ActiveChart.ChartArea.Copy
    Set pptSlide = pptPres.Slides(4)
    pptPres.Slides(4).Select
    With pptSlide
    .Shapes.PasteSpecial link:=False
    ‘.Shapes.PasteSpecial DataType:=ppPasteDefault, link:=msoFalse
    ‘.Shapes.PasteSpecial DataType:=ppPasteOLEObject, link:=msoFalse
    With .Shapes(.Shapes.Count)
    .Left = 150
    .Top = 215.125
    .Width = 480
    .Height = 289.625
    End With
    End With

    Viewing 0 reply threads
    Author
    Replies
    • #1326285

      Not sure this will work, but you could try:

      pptApp.CommandBars.ExecuteMso (“PasteAsEmbedded”)

      Gary

      • #1326542

        Thanks Gary,

        unfortunately that paste it as an object, the same that the option “.Shapes.PasteSpecial DataType:=ppPasteOLEObject, link:=msoFalse” does…

        As an object is one of my options but the charts doen’t look as pretty and editing them takes a lot of time…

        thanks for the reply Gary!!

        Regards

        Manu

        • #1328380

          Try the following. Then when you do the paste you will get a picture that should look good and not be linked to the excel file.

          Brian in Austin, Texas

          If TypeName(ActiveChart) = “Chart” Then
          ActiveChart.CopyPicture Appearance:=xlPrinter, Size:=xlScreen, Format:=xlPicture
          Else
          Selection.CopyPicture Appearance:=xlPrinter, Format:=xlPicture
          End If

    Viewing 0 reply threads
    Reply To: How to paste unlinked charts from Excel to PowerPoint using VBA

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: