My code has:
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture
Set PasteSlideShape = mPPSlide.Shapes.PasteSpecial(PasteDataType)
where I have tried all values of 0..11 for the DataType parameter
But I get for type 2 (bitmap)
'Run-time error '-2147188160 (80048240)':
'Shapes (unknown member) : Invalid request. The specified data
type is unavailable.
only datatypes 0,2,3 work. I use 0 (default, which is the same as Metafile)
I've googled for this and got these refs:
Excel 2007 copy chart as bitmap cannot paste as ppBitMap into Powerpoint 2007
http://www.pcreview.co.uk/forums/thread-3883121.php
PasteSpecial of Device Independent Bitmap with VBA in PP2007
in the full list of Excel 2007 SP2 fixes we see :
The VBA method Selection.CopyPicture does not copy the bitmap picture format
to the clipboard.
Excel..About says I have SP2
http://www.ozgrid.com/forum/showthread.php?t=73114
Re: Picture Copied as BitMap Ends Up As Metafile
Andy Pope says: "For me in 2007 this code copies the chart as a bitmap and
pastes into powerpoint as expected."
ActiveSheet.Shapes(1).CopyPicture Appearance:=xlScreen, Format:=xlBitmap
objPPTSld.Shapes.PasteSpecial ppPasteBitmap
but I get the error as shown above.
Any ideas?
TIA
Patrick
- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/
> Excel 2007 charts look like crap when exported as metafiles. Change
> CopyPicture so it copies the chart as a bitmap. In either case you only
> need to paste regular in PowerPoint.
I did that John, the client says they look just the same.
I tried all six combinations of
chart.copypicture with xlbitmap and xlpicture
and
slides.pastespecial with datatypes 0,2,3
' 0 ppPasteDefault
' 1 ppPasteBitmap
' 2 ppPasteEnhancedMetafile
' 3 ppPasteMetafilePicture ' same as default, truncated if too wide
' 4 ppPasteGIF
' 5 ppPasteJPG
I can indeed only paste regular (default) in Powerpoint 2007, get error if I
use bitmap datatype.
Thanks,
Patrick
I've done more tests. Here is the new code with an extra step / workaround
/ kludge.
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture
' for the Shape tests, convert it to a picture in Excel first then copy it,
so the other formats become available except 7,8,9
ActiveSheet.Paste ' will delete this copy shape later below
' have to do this to get the shape because activesheet.paste returns boolean
Set shp = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
shp.copy
mPPSlide.Shapes.PasteSpecial(PasteDataType)
I can't embed images here AFAIK but if you want samples I can email them to
you
I'll check whether the blurry effect on the text labels in the chart is from
resizing but at the moment ppPasteBitmap is best, PNG is usable. OTOH 2,3,10
look best in Windows so they'll have to choose what they want !
' PpPasteDataType: Mac text effect
' 0 ppPasteDefault broken
' 1 ppPasteBitmap good, a little fuzzy
' 2 ppPasteEnhancedMetafile broken
' 3 ppPasteMetafilePicture broken
' 4 ppPasteGIF bold, most blurry
' 5 ppPasteJPG bold, medium blurry
' 6 ppPastePNG bold, less blurry
'10 ppPasteOLEObject badly broken
'11 ppPasteShape badly broken
7,8,9 are text data formats, not applicable here
Thanks,
Patrick
And while I said bitmaps in 2007 were better than metafiles, they still
look awful.
- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/
That expression ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
is awkward too, it would be easier to have a paste method that returns the
pasted object.
Anyway, it occurs to me (only now!) that this is really a Powerpoint
question. I'll ask in the PP Forums about what fonts are safe to use on both
PC and Mac so that the metafile pictures render correctly in both Windows and
Mac.
Regards
Patrick
- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/