C# How to read/update activex combobox from an Excel Macro-Enabled Workbook file (xlsm) -
i developing c# application opens, reads , updates excel macro-enabled workbook file (xlsm). able read , update cells not able read/update activex control, combobox.
using excel = microsoft.office.interop.excel;
using msform = microsoft.vbe.interop.forms;
i tried different recipes based on research (http://forums.asp.net/t/1244356.aspx/1/10) trying read selected item:
excel.shape ashape = xlworksheet.shapes.item(name);
object o = ashape.oleformat.object;
msform.combobox newbox = (msform.combobox)(((excel.oleobject)o).object);
or alternatively
excel.oleobject cb1 = (excel.oleobject)xlworksheet.oleobjects(name);
msform.combobox combo1 = (msform.combobox)cb1.object;
but when try run code following error:
system.invalidcastexception : unable cast com object of type 'system.__comobject' interface type 'microsoft.vbe.interop.forms.combobox'. operation failed because queryinterface call on com component interface iid '{8bd21d33-ec42-11ce-9e0d-00aa006002f3}' failed due following error: interface not registered (exception hresult: 0x80040155).
here details of environment:
- windows 7 64bit
- ms visual studio 2008 professional edition
- .net 3.5 sp1
- microsoft excel 14.0.6129.5000 (32-bit)
as project references, added .net components:
path: c:\program files (x86)\microsoft visual studio 9.0\visual studio tools office\pia\office12\microsoft.office.interop.excel.dll
runtime version: v1.1.4322
version: 12.0.0.0
path: c:\program files (x86)\microsoft visual studio 9.0\visual studio tools office\pia\office11\microsoft.vbe.interop.forms.dll
runtime version: v1.1.4322
version: 11.0.0.0
any ideas on reason? if know how change selected item combobox please share :)
thank you!
Comments
Post a Comment