From: Marc on 4 Jan 2010 08:00 Hi, I am working to make an aplication that open an existing excel file, search for some text and notifies the result. Now, when I run it, before the excel file's opens get this error: COMException Types mismatch (Exception HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) My code is: object oMissing = System.Reflection.Missing.Value; Excel.ApplicationClass oExcel = new Excel.ApplicationClass(); oExcel.Visible = true; Excel.Workbooks oBooks = oExcel.Workbooks; Excel._Workbook oBook = null; oBook = oBooks.Open(path, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing); Object cad = Cadena.Text; Object LookIn = "xlValues"; Object LookAt = "xlWhole"; Microsoft.Office.Interop.Excel.XlSearchDirection xlApp = new Microsoft.Office.Interop.Excel.XlSearchDirection(); Object resultat = oBook.Sheets.Application.Cells.Find(cad, oMissing, LookIn, LookAt, oMissing, xlApp, oMissing, oMissing, oMissing).Activate(); // Quit Excel and clean up. oBook.Close(false, oMissing, oMissing); System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook); oBook = null; System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks); oBooks = null; oExcel.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel); oExcel = null; Another problem I probably will have is to run the find function for all sheets. thanks for advanced. Marc
|
Pages: 1 Prev: Retrieving current worksheet backgroud picture Next: ADO syntax problem |