Insert Excel Chart into Word document fails intermittently

J

JOHNV

Hi all,
I am using C# and Word Interop to insert a chart into a Word document. Most
of the time it works fine, but at odd intervals it will just not work. I
create the chart using C#, which always works, and save it into Windows
directory. Then, I copy the chart into an open Word document. Here's my
code:
oClassType = "Excel.Chart.8";
oFileName = "someFile.xls";

Word.Shape iShape = theRange.InlineShapes.AddOLEObject(
ref oClassType,
ref oFileName,
ref doc_missing,
ref doc_missing,
ref doc_missing,
ref doc_missing,
ref doc_missing,
ref doc_missing);


Maybe 10 times in succession, it works perfectly. Then one time, the file
will not be copied, and no object reference will be returned. iShape will
just be null, and there will be no exception thrown, as far as I can tell.

Does anyone have any ideas? Your thoughts would be most appreciated!

Thanks,
Johnv
 
J

JOHNV

Once I isolated the problem code, here is the exception information:

The server threw an exception. (Exception from HRESULT: 0x80010105
(RPC_E_SERVERFAULT))


It's almost as if the server goes on break every so often, and is not
available.

Any thoughts??

Thanks,
John
 

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