View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Confrimation of copy paste operation

I believe a chart will always copy. I suspect the _chObj may be empty
(null). I would set _chObj to Null before you assign the chart, then test if
it is still null afterwards before you do the copy.

"GS80" wrote:

Hi,

In my application (C#, Office 2007), i am attempting to copy a range of
cells containing data to a range on another worksheet. Upon copying the range
I then copy a chart into a specific area on the second worksheet. The chart
is resized and set up to represent a datapoint per row of data so the chart.

Occasionally (and i mean occasionally, i cannot replicate the problem 100%
of the time) the chart does not get copied to the second worksheet. I do this
a number of times for various different table ranges. Sometimes there will be
a number of these charts copied to the same output worksheet and i have
encountered this issue where by only some of the charts copy and others don't.

I generally use the following code to do the copy paste

_chObj = (ChartObject)_excelDataWS.ChartObjects("ChartName" );
_chObj.Copy();
_excelPresentationWS.Paste(_presTopLeftRange), paramMissing);

I have a couple of questions on this problem.

1) Is there a benefit to using the following copy command?:
_chObj.CopyPicture(XlPictureAppearance.xlScreen,
XlCopyPictureFormat.xlPicture);

2) Is there any way to confirm that a copy/paste operation has succeeded and
if not then to retry it?

I'm really having no joy in diagnosing why this is happening. I get no
exceptions thrown when the charts do not appear.

Any help is greatfully recieved.

Thanks in advance,

G