Macro Excel won't past exact image to Powerpoint Presentation

The strangest thing is happening with my macro in Excel. It works like a charm, but when it has to copy 2 charts and paste into my powerpoint presentation, suddenly, the Chart isn't exactly the same.

My code:

Set Wb = Workbooks.Open("PathWbName.xlsx", ReadOnly:=True, UpdateLinks:=0) 

It opens 5 more workbooks... And then it goes through a loop, to copy all the Charts

Dim Charts_Arr As Variant
    Charts_Arr = Worksheets("Parameters").ListObjects("Parameters").DataBodyRange.Value

For i = LBound(Charts_Arr) To UBound(Charts_Arr)
    SourcePath = Charts_Arr(i, 8)
    SheetName = Charts_Arr(i, 4)
    ShapeNr = Charts_Arr(i, 2)
    SlideNr = Charts_Arr(i, 3)
    Schaling = Charts_Arr(i, 6)

    Set Source = Workbooks(SourcePath)
    Set PPpres = oPPTApp.ActivePresentation
    Set Sh = Source.Sheets(SheetName).Shapes(ShapeNr)


    Sh.Copy


    Set NewSh = PPpres.Slides(SlideNr).Shapes.PasteSpecial(ppPasteJPG)
    With NewSh
      .Top = Charts_Arr(i, 5)
      .Left = Charts_Arr(i, 7)
      .ScaleHeight Schaling, msoTrue
    End With

Next i

This goes perfectly. But when I take a look at the ppt-file, 2 charts are not exactly the same.

(TIP: Excel is Chartarea, not a shape - didn't know this at first)

白色线在27/11之后下降

When copy the picture manually, I get the correct picture:

在这里输入图像描述

And what's more bizarre, I have 2 other Charts on another Sheet in the same workbook who doesn't cause any problems.

Could this be a problem with links, or the way I copy?

UPDATE

If I adjust the code as suggested below:

 Source.Sheets(SheetName).ChartObjects(ShapeNr).Chart.CopyPicture
        Set NewSh = PPpres.Slides(SlideNr).Shapes.Paste
            With NewSh
                        .Top = Charts_Arr(i, 5)
                        .Left = Charts_Arr(i, 7)
                        .ScaleHeight Schaling, msoTrue
            End With  

I get this:

CopyPicture

I'm doing something wrong with the Paste part of the code, I guess. Tried other possibilities, always end up getting no images, or the one above.

FIXERSUPDATE

So I made/used a loophole. Couldn't find a way to paste the images directly into Powerpoint, So I pasted it into an excelsheet 'Temp' instead. And adjusted the Array, and that seemed to work. But I still would like to know how to do this directly in Powerpoint.

Thanks in advance for your insights!


I couldn't find a PasteSpecial Option that could fix the issue. CopyasPicture works, but I can't seem to figure out how to paste it directly into ppt. So I used a workaround. I created a 'Temp' Sheet, where I could paste the Chart as Picture in the right format, afterwards I could program it to paste the shape into Ppt. Not the cleanest way to solve the issue, but it works.

链接地址: http://www.djcxy.com/p/45686.html

上一篇: PowerPoint中Excel图表的灰色边框(2010)

下一篇: 宏Excel不会通过精确的图像到Powerpoint演示文稿