Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Macro Copy/Paste error

Try adding a dot in front of Chart.Area.Select...
With cht
.ChartArea.Select
.Paste
End With
--
Jim Cone
Portland, Oregon USA



"Deorum"
wrote in message
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple copy paste multiple range macro ARGUMENT ERROR Bruno Excel Programming 2 October 22nd 08 01:33 AM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
Cut and Paste using Macro gives paste special method error Lourens Pentz Excel Programming 3 November 21st 04 10:42 PM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 08:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"