LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 347
Default Excel 2000 open using C# error - Unable to cast COM object of type

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.ReleaseComO bject(wksExcel);

System.Runtime.InteropServices.Marshal.ReleaseComO bject(wbkExcel);

System.Runtime.InteropServices.Marshal.ReleaseComO bject(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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to cast ..Excel.ApplicationClass to ..Excel._Application yh Excel Discussion (Misc queries) 0 April 27th 10 07:08 AM
Unable to cast com object (interop) yh Excel Discussion (Misc queries) 0 April 26th 10 09:16 AM
Unable to open Excel 2000 Lisa W. Excel Discussion (Misc queries) 0 February 11th 09 04:28 PM
Object Required Error, Excel 2000 & 2003 jfcby[_2_] Excel Programming 3 July 31st 07 08:10 PM
recipient unable to open excel 2003 doc with excel 2000 FMF DOC New Users to Excel 2 July 21st 05 04:57 PM


All times are GMT +1. The time now is 09:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"