By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

Creating a chart in Excel from C# (Exception from HRESULT: 0x800A03EC)

P: 2
I am trying to create an Excel chart from C#. I am not a very experieced programmer, so my mistake could be very trivial. The code included is a very simple example. I just wanted to make sure the code runs first before I implement it into my application.
The code is supposed to plot for X values: column A in excel and for Y values: column B in Excel. The code up to the point and including exporting the data to excel runs properly. When I implement the code relating to plotting, I get a COMException; Exception from HRESULT: 0x800A03EC.

Expand|Select|Wrap|Line Numbers
  2. ...
  4. Range theRange6 = theWorkSheet.get_Range("A1", "B50");
  5. theRange6.Select();
  6. ChartObjects chartobjects = (ChartObjects)theWorkSheet.ChartObjects(Type.Missing);
  7. ChartObject chartobject = (ChartObject)chartobjects.Add(10 /*Left*/, 100 /*Top*/, 450 /*Width*/, 250 /*Height*/);
  8. _Chart chart = (_Chart)chartobject.Chart;
  10. //chartobject.Chart.ChartWizard parameters are from MSDN help.
  11. chartobject.Chart.ChartWizard(theRange6, XlChartType.xlXYScatterSmooth, 1, XlRowCol.xlColumns, 0, 0, true, "Test", "x", "y", ""); 
  13. theApplication.Visible = true;
Could you please advise me on what I could be doing wrong? Any help would be greatly appreciated.
Thank you,
Jul 9 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.