Confrimation of copy paste operation

G

GS80

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
 
J

Joel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top