wildfire1982 Posted March 3, 2004 Posted March 3, 2004 Hello folks, I have used excel from vb.net loads of times and normally manage it with no problems. This time, I have one event opening the spreadsheet and associating it with an object, and then another event which writes to the spreadsheet. Everything seems fine apart from when it is run and the line which the error occurs in should simply write to a cell. I get the message HRESULT: 0x800A03EC. The objects are defined in the main body of the code as public and each of the events metioned earlier refer to these. Anyone had this problem before? Im sure its probably just me being stupid as usual but I cant see where im going wrong. Cheers for any ideas. Chris Quote Chris
cee Posted March 9, 2004 Posted March 9, 2004 I have had the same error, and searched for it for about an hour, eventually I found the solution. I had written a loop to write different values into different cells. It went something like this: for i = 0 to 10 sheet.cells("A" & i) = "test" next Actually it's quite obvious, but there is no cell "A0" :-) You should start counting from one... Quote
Arch4ngel Posted April 19, 2004 Posted April 19, 2004 I got the following error : Exception from HRESULT: 0x800A03EC. Which is the same. I'm doing it on ASP.NET with C#. I want the server-side to interpret Data from a excel file. Here is my code : [size=2][color=#0000ff]private[/color][/size][size=2][color=#0000ff]void[/color][/size][size=2] Button1_Click([/size][size=2][color=#0000ff]object[/color][/size][size=2] sender, System.EventArgs e)[/size] [size=2]{[/size] [size=2] Workbooks oWbs = [/size][size=2][color=#0000ff]null[/color][/size][size=2];[/size] [size=2] Workbook oWb = [/size][size=2][color=#0000ff]null[/color][/size][size=2];[/size] [size=2][color=#0000ff] try[/color][/size] [size=2] { [/size] [size=2] oWbs = oExcel.Workbooks;[/size] [size=2] oWb = oWbs._Open(@"C:\Inetpub\wwwroot\Location\tests.xls",[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2],[/size][size=2][color=#0000ff]null[/color][/size][size=2], [/size][size=2][color=#0000ff]null[/color][/size][size=2]);[/size] [size=2] Response.Write("It works");[/size] [size=2] Response.Write("<br>");[/size] [size=2] }[/size] [size=2][color=#0000ff] catch[/color][/size][size=2](Exception ex)[/size] [size=2] {[/size] [size=2] NAR( oWbs );[/size] [size=2] NAR( oWb );[/size] [size=2] oExcel.Quit();[/size] [size=2] NAR(oExcel);[/size] [size=2] Response.Write( ex.Message );[/size] [size=2] }[/size] [size=2]}[/size] Thanks Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Administrators PlausiblyDamp Posted April 19, 2004 Administrators Posted April 19, 2004 Do the suggestions here fix anything? It sounds like it could be a permissions problem. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Arch4ngel Posted April 19, 2004 Posted April 19, 2004 That's it. I solved the problem... I think :D I changed Open(filename) by Add(filename) and it work. At least it return a value. Oh... yes I set the right permission to ASPNET account (fullcontrol). I think it's maybe an old command for older Excel or something or I dunno. I have another problem with getting the right range. I want to have all columns header (A1:A??). But it said invalid type : Range rng = ws.Columns.get_range( ws.Columns.Cells["A", "1"], ws.Columns.Cells["A", ws.Columns.Count.ToString()]; Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Administrators PlausiblyDamp Posted April 19, 2004 Administrators Posted April 19, 2004 Why are you doing the ws.columns.Count.ToString() ?? Shouldn't it be just ws.columns.Count Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Arch4ngel Posted April 19, 2004 Posted April 19, 2004 Because in the first parameter I putted a string so I tought that I shall be constant. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Arch4ngel Posted April 19, 2004 Posted April 19, 2004 However ... here is my exact code : [size=2][color=#0000ff]public[/color][/size][size=2][color=#0000ff]string[/color][/size][size=2] [] GetColumnsHeaders() { Range rng = [/size][size=2][color=#0000ff]null[/color][/size][size=2]; [/size][size=2][color=#0000ff]try [/color][/size][size=2]{ rng = m_ws.Columns.get_Range( m_ws.Columns.Cells["A",1], m_ws.Columns.Cells["A", m_ws.Columns.Count]); [/size][size=2][color=#0000ff]string[/color][/size][size=2] [] test = [/size][size=2][color=#0000ff]new[/color][/size][size=2][color=#0000ff]string[/color][/size][size=2][rng.Count]; NAR( rng); [/size][size=2][color=#0000ff]return[/color][/size][size=2] test; } [/size][size=2][color=#0000ff]catch [/color][/size][size=2]{ NAR( rng ); Dispose(); [/size][size=2][color=#0000ff]return[/color][/size][size=2][color=#0000ff]null[/color][/size][size=2]; } } [/size] [edit2]The NAR function is the one that were so much talked about but translated to C#.[/edit2] Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Arch4ngel Posted April 19, 2004 Posted April 19, 2004 Stop everything there. I'm stupid and I admit it. m_ws.Cells[1,1] work better than m_ws.Cells["A", 1]. You can throw me rocks if you want. It seems to calm stupidy in my damn head also. Thanks anyway dude ! Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Recommended Posts