Group:  Microsoft Word ยป microsoft.public.word.oleinterop
Thread: Closing Excel workbook throws 'Exception from HRESULT: 0x800A03EC'

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Closing Excel workbook throws 'Exception from HRESULT: 0x800A03EC'
IserSchou 14.09.2006 08:47:01
I am developing an Office 2003 SmartDocument application where Excel charts
in the document are to be populated with data from C# code.
The following code handles the update of all Excel charts in the document:

System.Globalization.CultureInfo ciOld =
System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-US");
try
{
foreach (InlineShape objShape in wordDocument.InlineShapes)
{
if (objShape.OLEFormat != null &&
objShape.OLEFormat.ClassType == "Excel.Chart.8")
{
objShape.Activate();
Microsoft.Office.Interop.Excel.Workbook objWorkBook
= (Microsoft.Office.Interop.Excel.Workbook)objShape.OLEFormat.Object;
Microsoft.Office.Interop.Excel.Application objApp =
objWorkBook.Application;
// Some code to manipulate the workbook...
objApp.Workbooks.Close();
objApp.Quit();
}
}
}
catch (Exception e)
{
MessageBox.Show("Error: " + e.Message, "",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
System.Threading.Thread.CurrentThread.CurrentCulture = ciOld;
}

Executing the code as displayed above, throws an exception (Exception from
HRESULT: 0x800A03EC) in the line containing 'objApp.Workbooks.Close();' for
the first chart encountered.

Omitting the call will leave the chart selected in the document hiding the
Actions Pane which is NOT intended.

Using objWorkBook.Close() also results in the same exception being thrown.

Am I missing something - is there a workaround - suggestions are very welcome.



Re: Closing Excel workbook throws 'Exception from HRESULT: 0x800A03EC'
Cindy M. <C.Meister-C[ at ]hispeed.ch> 14.09.2006 14:13:46
See my response to GailHurn "How do you close embedded
workbook in Word?" in the Office.Developer.Office.SDKs
newsgroup.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)

Re: Closing Excel workbook throws 'Exception from HRESULT: 0x800A0
IserSchou 15.09.2006 07:19:02
Wow! Thank you very much Cindy.

After experimenting a little with the DoVerb I got a solution where my Excel
Graph objects are all populated with data and drawn without any flickering
what so ever.

Again, thank you very much.

Morten Schou
Medtronic A/S, Denmark

"Cindy M." wrote:

[Quoted Text]
> See my response to GailHurn "How do you close embedded
> workbook in Word?" in the Office.Developer.Office.SDKs
> newsgroup.
>
> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister (last update
> Jun 17 2005)
> http://www.word.mvps.org
>
> This reply is posted in the Newsgroup; please post any
> follow question or reply in the newsgroup and not by e-mail
> :-)
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net