troubleshooting Question

Excel throws Exception from HRESULT: 0x800A03EC

Avatar of iserschou
iserschou asked on
Programming
5 Comments1 Solution1033 ViewsLast Modified:
I am developing an Office 2003 SmartDocument application where Excel charts in the document are to be populated with data from 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.

Am I missing something - is there a workaround - suggestions are very welcome.
ASKER CERTIFIED SOLUTION
Computer101

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros