G
george
Hi,
I am using Excel 2000 with C# in VS 2008. I added the excel 9.0 reference
from COM tab under Reference. I am using VS 2008 and win forms.
The code snippet is given below :
Excel.Application appExcel = new Excel.Application();
appExcel.DisplayAlerts = false;
Excel.Workbook wbkExcel = appExcel.Workbooks.Open("C:\\emp.xls",
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing); //<--Error here
Excel.Worksheet wksExcel = (Excel.Worksheet)wbkExcel.Sheets[0];
wksExcel.Activate();
wbkExcel.Close(false, Type.Missing, Type.Missing);
appExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(wksExcel);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wbkExcel);
System.Runtime.InteropServices.Marshal.ReleaseComObject(appExcel);
wksExcel = null;
wbkExcel = null;
appExcel = null;
GC.Collect();
The error is :
"Unable to cast COM object of type
'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type
'Microsoft.Office.Interop.Excel._Application'. This operation failed because
the QueryInterface call on the COM component for the interface with IID
'{000208D5-0000-0000-C000-000000000046}' failed due to the following error:
Library not registered. (Exception from HRESULT: 0x8002801D
(TYPE_E_LIBNOTREGISTERED))."
Any help is appreciated.
Thanks.
george
I am using Excel 2000 with C# in VS 2008. I added the excel 9.0 reference
from COM tab under Reference. I am using VS 2008 and win forms.
The code snippet is given below :
Excel.Application appExcel = new Excel.Application();
appExcel.DisplayAlerts = false;
Excel.Workbook wbkExcel = appExcel.Workbooks.Open("C:\\emp.xls",
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing); //<--Error here
Excel.Worksheet wksExcel = (Excel.Worksheet)wbkExcel.Sheets[0];
wksExcel.Activate();
wbkExcel.Close(false, Type.Missing, Type.Missing);
appExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(wksExcel);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wbkExcel);
System.Runtime.InteropServices.Marshal.ReleaseComObject(appExcel);
wksExcel = null;
wbkExcel = null;
appExcel = null;
GC.Collect();
The error is :
"Unable to cast COM object of type
'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type
'Microsoft.Office.Interop.Excel._Application'. This operation failed because
the QueryInterface call on the COM component for the interface with IID
'{000208D5-0000-0000-C000-000000000046}' failed due to the following error:
Library not registered. (Exception from HRESULT: 0x8002801D
(TYPE_E_LIBNOTREGISTERED))."
Any help is appreciated.
Thanks.
george