471,350 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

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

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
0 4737

Post your reply

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

Similar topics

reply views Thread by e-lores | last post: by
1 post views Thread by Boomessh | last post: by
18 posts views Thread by Frank M. Walter | last post: by
5 posts views Thread by Mikil | last post: by
reply views Thread by tmg181 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.