PDA

View Full Version : chart/ paste special



mg25683
04-04-2018, 12:33 AM
21969
I would like to paste a NOT linked chart from excel to a power point slide.
I am not sure how the pastespecial option is called in english (probably something like "keep source formatting and embed the worksheet")

I use


(...).chartObject.chart.ChartArea.copy
(...).slide.Shapes.PasteSpecial(ppPasteShape, link:=msoFalse)


but the ppPasteDataType enum members do not correspond with what i see in the UI and the "link" param doesn't seem to do anything - the chart is linked regardless of its value.


Any advice?

John Wilson
04-04-2018, 02:48 AM
You probably need to PasteSpecial with DataType:=ppPasteOLEObject ,Link:=False

ppPasteOLEObject is type 10 if you have not set a ref to PPT

mg25683
04-04-2018, 03:19 AM
thanks a lot, it works.
No idea how i missed that:)

John Wilson
04-04-2018, 03:41 AM
You're welcome

mg25683
04-04-2018, 05:52 AM
Hm, I was too quick to rejoice. After pasting the chart with params as above, it seems to be corrupted (some odd things happen with its size and formatting when you click it)
I ended up pasting it as a picture (as I do not want the fonts to get warped when you resize the shape, i do the following:




Call .slide.Shapes.PasteSpecial(ppPasteEnhancedMetafile)
Set myShape = .slide.Shapes(.slide.Shapes.count)
Call myShape.Ungroup