A
Abraham Andres Luna
hello everyone,
how do i click a commandbutton using .net and the Excel 11.0 Object Library
this is my code, but the error says it cannot cast system.__comobject to the
excel.oleobjectclass
Microsoft.Office.Interop.Excel.Application appExcel = new
Microsoft.Office.Interop.Excel.Application();
appExcel.Workbooks.Open(@"C:\RDK\Test.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,
Type.Missing, Type.Missing);
Microsoft.Office.Interop.Excel.Worksheet wsSetup =
(Microsoft.Office.Interop.Excel.Worksheet)appExcel.Sheets["Sheet1"];
Microsoft.Office.Interop.Excel.OLEObjectClass objRefresh =
(Microsoft.Office.Interop.Excel.OLEObjectClass)wsSetup.OLEObjects("CommandButton1");
//After casting it i guess i want to call the click method
//objRefresh.Click() or something
string strType = objRefresh.OLEType.ToString();
appExcel.ActiveWorkbook.Close(false, Type.Missing, Type.Missing);
appExcel.Quit();
MessageBox.Show(strType);
thank you for your help
how do i click a commandbutton using .net and the Excel 11.0 Object Library
this is my code, but the error says it cannot cast system.__comobject to the
excel.oleobjectclass
Microsoft.Office.Interop.Excel.Application appExcel = new
Microsoft.Office.Interop.Excel.Application();
appExcel.Workbooks.Open(@"C:\RDK\Test.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,
Type.Missing, Type.Missing);
Microsoft.Office.Interop.Excel.Worksheet wsSetup =
(Microsoft.Office.Interop.Excel.Worksheet)appExcel.Sheets["Sheet1"];
Microsoft.Office.Interop.Excel.OLEObjectClass objRefresh =
(Microsoft.Office.Interop.Excel.OLEObjectClass)wsSetup.OLEObjects("CommandButton1");
//After casting it i guess i want to call the click method
//objRefresh.Click() or something
string strType = objRefresh.OLEType.ToString();
appExcel.ActiveWorkbook.Close(false, Type.Missing, Type.Missing);
appExcel.Quit();
MessageBox.Show(strType);
thank you for your help