View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Deorum Deorum is offline
external usenet poster
 
Posts: 1
Default Macro Copy/Paste error

I've been handed a piece of code and told to work out why it's
breaking. Basically There is a for loop that copies a range using
CopyPicture, and pastes it into a chart object to finally export the
chart as a JPEG.

What I am getting is an error - 1004 Microsoft Excel cannot paste the
data.

This error will occur at random times and it seems to happen sooner
with more processes running.

I can get through approx x number of iterations, close the book,
repoen and start again from x getting approx the same number of
iterations.

Any Ideas? Thanks in advance...

rngSelection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

' Add a chart object to the activesheet
Set cto = ActiveSheet.ChartObjects.Add(0, 0, 800, 600)
Set cht = cto.Chart

' Paste the picture onto the chart and set an object variable for it
cto.Activate
With cht
ChartArea.Select
.Paste
End With