View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.charting,microsoft.public.excel.programming
Fredrik E. Nilsen Fredrik E. Nilsen is offline
external usenet poster
 
Posts: 43
Default Copy chart to clipboard - VBA

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