I am adding a checkbox to excel and i have issue casting a COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.CheckBox', any help would be appreciated! I am working on web app using visual studio 2008 and office 2007. The error happens at this line :- chkBx = (Microsoft.Office.Interop.Excel.CheckBox)obj;
Microsoft.Office.Interop.Excel.OLEObjects objs = (Microsoft.Office.Interop.Excel.OLEObjects)mWSheet1.OLEObjects(System.Reflection.Missing.Value);
Microsoft.Office.Interop.Excel.OLEObject obj = objs.Add("Forms.CheckBox.1",
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
false,
false,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
234,
234,
108,
21);
Microsoft.Office.Interop.Excel.CheckBox chkBx;
chkBx = (Microsoft.Office.Interop.Excel.CheckBox)obj;
chkBx.Value = true;
chkBx.Caption = "xyz";