View Single Post
  #3   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

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

Regards,
Peter

"Fredrik E. Nilsen" wrote in message
...
Hi again,

I'm trying to use VBA to:

- copy a chart in a chart sheet
- paste it as an embedded chart in a new sheet
- resize (and format) the chart
- copy the embedded chart to the clipboard
- delete the new sheet

This is the code I've come up with so far:

Sub CopyChart()
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
ActiveWorkbook.Sheets.Add
ActiveSheet.Paste
ActiveSheet.ChartObjects("Chart 1").Activate
With ActiveChart.Parent
.Height = 252.75
.Width = 342.75
ActiveChart.PlotArea.Height = 205
ActiveChart.PlotArea.Width = 340
ActiveChart.ChartArea.Copy
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
End With
End Sub

The problem is: when the ActiveSheet is deleted, the copied chart is
no longer available on the clipboard. I can use the CopyPicture method
in stead, but then there will be a different size when pasted in
another application.

--
Fredrik E. Nilsen