470,625 Members | 1,992 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,625 developers. It's quick & easy.

Exception from HRESULT: 0x800A03EC when I Select and object

1
Hi friends,
I have an application, written in C#, in which I am updating an Excel spreadsheet with data I pull from a sql database. When I try to select a cell in where I want to begin inserting my data I get the error -- Exception from HRESULT: 0x800A03EC (what does this mean?). I've searched the web and have been unsuccessful in finding a viable solution to the error. A snippet of my code is below:

Excel.Range cf = null;
// Create application object...
Excel.Application XcelApp = new Excel.ApplicationClass();
// I want to open an existing document for editing instead
// of creating a new one...
Excel.Workbook XcelWorkBook = XcelApp.Workbooks.Open(xlWorkBookPath,
0, false, 5, Type.Missing, Type.Missing, false,
Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);

// initialize Excel objects...
Excel.Sheets XcelWorkSheets = XcelWorkBook.Worksheets;
Excel._Worksheet XcelWorkSheet = null;

// hide the app...
XcelApp.Visible = false;

Not ot bore anyone, but I open my workbook, locate and Activate my current worksheet; find the column I want and so on...
...
...
...

The error is when I try to select a specific location on my worksheet:


for (int i = 1; i <= dt.Rows.Count; i++)
{
curId = dt.Rows[i - 1].ItemArray[0].ToString();

if (counter.Equals(0)) row = 26; // next row...
if (counter.Equals(1)) row = 50; // ...
if (counter.Equals(2)) row = 74;
if (counter.Equals(3)) row = 98;

if (Int32.Parse(prvId) < Int32.Parse(curId)) // next row and so on...
{
This is where I get the exception
// It consistantly fails whenever counter is equal to 3.
XcelWorkSheet.Select(cellFound[row, col]);

prvId = curId; // current source id to previous source id
counter++;
...
... // do some more stuff...
}
}
Aug 30 '07 #1
0 1656

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
4 posts views Thread by Mark | last post: by
8 posts views Thread by scorpion53061 | last post: by
5 posts views Thread by Mikil | last post: by
reply views Thread by Stephen Plotnick | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.