View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Paste chart images macro fails

Errors like 2147417848 (80010108)' I usally find are caused by one of two
reasons

1) The window or form lost the focus. Some other window has activated
another window taking the focus. Tthe code is pasting the picture into the
wrong active window. Make sure you are referenceing the window/form by an
object name and not using the active window.

2) A similar problem to one abvove if you have multiple forms and you don't
have the priledge from one form to access another form because the form is
declared as private.

"Anand Nichkaode" wrote:

Hi all,

We are using Excel for reporting in our organization. Basically there is a
Java web application which instantiates Excel 2007 with an XLAM. This XLAM
opens a Report Template(an .xls, .xlsm file, name supplied as command line
parameter). The Template has a datasheet where we have multiple ranges and
the Reportsheet which shows the final report based on the data from the
Datasheet. The Reportsheet contains formulas to show the final output. It
could contain Charts/Graphs also. The data is fetched from SQL server and is
pasted on the Ranges. And finally when all the data is pasted and Macro is
run the Template is saved as a Final Report somewhere on the Report Server.
The Excel runs in the background in all this process. There could be multiple
instances of Excel running on the same box. The instances run under separate
WindowStation.

In this process a macro,PasteChartAsGraphic, present in the template is
invoked by the XLAM. The macro basically is about pasting the images of the
charts present in the template and later deleting the original charts. So the
template would be left with the chart images instead of actual chart objects
after the macro is Run.

The macro executes successfully for most of the times but failes randomly
with different errors. Last time it failed with the following error. Excel
ends up in showing the following dialog box.

"Microsoft Visual Basic". The dialog contained the following text content:
[Run-time error '-2147417848 (80010108)':##Method 'CopyPicture' of object
'ChartObject' failed][&Continue][&End][&Debug][&Help]

I can post the macro code if anybody is interested in looking into it.

If anybody have any idea please let me know as it is a blocking issue in our
process.

Any help appreciated.

Thanks in advance.