View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Copy chart to clipboard - VBA

"Fredrik E. Nilsen" wrote in message
...
On Sat, 21 Apr 2007 14:04:15 +0100, "Peter T" <peter_t@discussions
wrote:

Hi Fredrick,

can use the CopyPicture method
in stead, but then there will be a different size when pasted in
another application.


I just tried that and it worked fine for me after deleting the chart then
pasting into an image processor, having first running this recorded

macro -

ActiveChart.CopyPicture Appearance:=xlScreen, _
Size:=xlScreen, Format:=xlBitmap

If the other application is Word it may well resize.

Perhaps try different permutations of options when you do Shift Edit
CopyPicture...

You might also look into the Export method


Thanks for your reply Peter.

Your macro would work as you describe, but with this, the chart will
not have the size and formatting the users want. When pasted in Word,
all charts should ideally have the same size and the same formatting.
With CopyPicture, it takes the size of the screen (xlScreen). Thats
why I have to copy the chart sheet, paste it as an embedded chart into
a new sheet, resize and format it, copy the new chart to the
clipboard, delete the new sheet with the new chart.

Now, I want to be able to paste the chart into Word or PowerPoint, but
when the new sheet is deleted, so is the chart on the clipboard.

--
Fredrik E. Nilsen


The clipboard stores a wide variety of information as 'formats'. If you
delete the chart while it's in the clipboard all the OLE info is lost. Try
copying a cell with data that has a format, eg a colour. Paste to a cell in
another wb works as expected. Delete the original source and paste again and
only the value as text will remain in the clipboard, even if the source was
a formula.

I quickly tried the copypicture a method again and found sometimes it would
paste into Word depending on the copypicture options, even after deleting
the chart (chartobject).

For other Office app's if pasting an image, it's probably better as Windows
Meta file. Perhaps it might be worth looking at Stephen Bullen's
PastePicture.zip http://www.oaltd.co.uk/Excel/Default.htm
Use the API to copy to the clipboard in desired format.

Regards,
Peter T