Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to paste unlinked charts from Excel to PowerPoint using VBA

    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

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 28 Times in 27 Posts
    Not sure this will work, but you could try:

    pptApp.CommandBars.ExecuteMso ("PasteAsEmbedded")

    Gary

  4. #3
    New Lounger
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  5. #4
    New Lounger
    Join Date
    Mar 2010
    Location
    austin, texas, usa
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •