Hi.....
I am using MS office 2003 and Visual studio 2008 .I have added a reference to Microsoft.Office.Interop.Excel 11.0 library .
Added the following code:
private void button1_Click(object sender, EventArgs e)
{
object format = 5;//Nothing value.
ApplicationClass xlApp = new ApplicationClass();
Workbook xlBook = xlApp.Workbooks.Open("D:\\WORKS\\App\\bin\\Debug", 0, false, format, null, null, false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, null, true, false, 0, true, false, false);
Sheets xlSheets = xlBook.Worksheets;
Worksheet xlSheet = (Worksheet)xlSheets.get_Item("Sheet1"); // open Sheet1.
xlApp.Visible = true;
}
Getting the error:
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: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
I dont think there is a pblm in the code, bcz.. it is work in other systems. i think some dll are missing while installation of ms office.I need a help on this basis
thanku

1 answers
You should replace
with
At least that's what I usually do ...
answered one year ago by:
2499