ERROR : Exception from HRESULT: 0x800A03EC
-
Hello All, I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook ObjWB;
Microsoft.Office.Interop.Excel.Worksheet ObjWS;
Object missing = System.Reflection.Missing.Value;
if (ObjExcel == null)
{
//'throw an exception
throw (new Exception("Unable to Start Microsoft Excel"));
}
else
{
ObjExcel.Visible = true;
ObjExcel.DisplayAlerts = false;
ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
Session["ExcelObject"] = ObjExcel;
Session["WorkBook"] = ObjWB;
Session["WorkSheet"] = ObjWS;
htxtFileName.Value = "SaveExcelFile/Excel1.xls";
}
}
catch (Exception ex)
{
Response.Write("Page Load Error : " + ex.Message);
}
}
}and On Save Button Click event I have the following code:
protected void btnSaveFileToServer_Click(object sender, EventArgs e)
{
try
{
if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
{
Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
ObjExcel.ThisWorkbook.Save(); -
Hello All, I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook ObjWB;
Microsoft.Office.Interop.Excel.Worksheet ObjWS;
Object missing = System.Reflection.Missing.Value;
if (ObjExcel == null)
{
//'throw an exception
throw (new Exception("Unable to Start Microsoft Excel"));
}
else
{
ObjExcel.Visible = true;
ObjExcel.DisplayAlerts = false;
ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
Session["ExcelObject"] = ObjExcel;
Session["WorkBook"] = ObjWB;
Session["WorkSheet"] = ObjWS;
htxtFileName.Value = "SaveExcelFile/Excel1.xls";
}
}
catch (Exception ex)
{
Response.Write("Page Load Error : " + ex.Message);
}
}
}and On Save Button Click event I have the following code:
protected void btnSaveFileToServer_Click(object sender, EventArgs e)
{
try
{
if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
{
Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
ObjExcel.ThisWorkbook.Save();Have you tried googling with the error message as the search string. You might find what it means.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Have you tried googling with the error message as the search string. You might find what it means.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
Thanks Paul for replying. Yes I have tried but didnt get much help :( I am not able to figure out what is the exact problem in the code. Please help me...
-
Thanks Paul for replying. Yes I have tried but didnt get much help :( I am not able to figure out what is the exact problem in the code. Please help me...
I've seen this kind of thing happen when there is an instance of Excel, ( or Word, doesn't really matter when using Office Interop ) that is not closed, and a New is invoked the second time through. I'd put a check in your code to make sure you are creating a single instance of Excel, and closing that instance when done with it.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Hello All, I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook ObjWB;
Microsoft.Office.Interop.Excel.Worksheet ObjWS;
Object missing = System.Reflection.Missing.Value;
if (ObjExcel == null)
{
//'throw an exception
throw (new Exception("Unable to Start Microsoft Excel"));
}
else
{
ObjExcel.Visible = true;
ObjExcel.DisplayAlerts = false;
ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
Session["ExcelObject"] = ObjExcel;
Session["WorkBook"] = ObjWB;
Session["WorkSheet"] = ObjWS;
htxtFileName.Value = "SaveExcelFile/Excel1.xls";
}
}
catch (Exception ex)
{
Response.Write("Page Load Error : " + ex.Message);
}
}
}and On Save Button Click event I have the following code:
protected void btnSaveFileToServer_Click(object sender, EventArgs e)
{
try
{
if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
{
Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
ObjExcel.ThisWorkbook.Save();In btnSaveFileToServer_Click....
ASP.NET 2.0 wrote:
Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"]; ObjExcel.ThisWorkbook.Save();
Add something like
ObjExcel.Quit
, so you can dispose of the Excel app when done with it."The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
In btnSaveFileToServer_Click....
ASP.NET 2.0 wrote:
Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"]; ObjExcel.ThisWorkbook.Save();
Add something like
ObjExcel.Quit
, so you can dispose of the Excel app when done with it."The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
thanks for the reply Paul, but its not working. now the error is coming on page load it self and excel file is not getting saved :( Please help me... Thanks again.
-
thanks for the reply Paul, but its not working. now the error is coming on page load it self and excel file is not getting saved :( Please help me... Thanks again.
Well, it's late here. I'm curious as to why this is a problem. I'll write my own little mock up of your code you are trying to do and see what is up. Stay tuned :)
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Well, it's late here. I'm curious as to why this is a problem. I'll write my own little mock up of your code you are trying to do and see what is up. Stay tuned :)
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
hey thanks Paul. I am trying this from yesterday but :( First I was getting Error "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005." I solved that but now getting this error. Thanks again.
-
hey thanks Paul. I am trying this from yesterday but :( First I was getting Error "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005." I solved that but now getting this error. Thanks again.
Hi, found a possible solution here: http://www.made4dotnet.com/Default.aspx?tabid=141&aid=15
-
Hello All, I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook ObjWB;
Microsoft.Office.Interop.Excel.Worksheet ObjWS;
Object missing = System.Reflection.Missing.Value;
if (ObjExcel == null)
{
//'throw an exception
throw (new Exception("Unable to Start Microsoft Excel"));
}
else
{
ObjExcel.Visible = true;
ObjExcel.DisplayAlerts = false;
ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
Session["ExcelObject"] = ObjExcel;
Session["WorkBook"] = ObjWB;
Session["WorkSheet"] = ObjWS;
htxtFileName.Value = "SaveExcelFile/Excel1.xls";
}
}
catch (Exception ex)
{
Response.Write("Page Load Error : " + ex.Message);
}
}
}and On Save Button Click event I have the following code:
protected void btnSaveFileToServer_Click(object sender, EventArgs e)
{
try
{
if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
{
Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
ObjExcel.ThisWorkbook.Save();Hi, I tried your code, I get the error even in my local dev machine. The error when executing the line "ObjExcel.ThisWorkbook.Save();" is : "Exception from HRESULT: 0x800A03EC". If you find the solution for the above, pls help me out to solve. Thanks Priya