Class not exists: NetOffice.OfficeApi.ComboBox

Jul 30, 2013 at 1:26 PM
Hi there

I'm about to access ActiveX controls by NetOffice. Using the following code:
Excel.OLEObjects objs = (Excel.OLEObjects)((Excel.Worksheet)ActiveWorkbook.ActiveSheet).OLEObjects(System.Reflection.Missing.Value);

((ComboBox)((Excel.OLEObject)objs["combo1"]).Object).AddItem("asdf");
The following exception is thrown: "Class not exists: NetOffice.OfficeApi.ComboBox"

Does anyone have an idea what is going on?
Thank you
Coordinator
Aug 5, 2013 at 8:20 PM
Edited Aug 5, 2013 at 8:33 PM
i'm wondering about the (ComboBox) cast. NetOffice doesnt contains a class with these name(except in the AccessApi namespace). where ist that from?

*sebastian


EDIT: i try to reproduce your scenario but it fails.
please contact via skype when its possible(username:public.Sebastian)
Aug 7, 2013 at 6:59 AM
ComboBox is from Microsoft.Vbe.Interop.Forms.

Actually the cast is not necessary. This is already causing the excpetion: (Excel.OLEObject)objs["combo1"])
NetOffice is trying to cast it to a NetOffice.OfficeApi.ComboBox
Coordinator
Aug 8, 2013 at 10:44 PM
hello again,

as hotfix please use:

using Vbe = Microsoft.Vbe.Interop.Forms;
Vbe.ComboBox comboBox = Invoker.PropertyGet(oleObject, "Object") as Vbe.ComboBox;
// stuff
Marshal.ReleaseComObject(comboBox);

please keep in your mind. Microsoft.Vbe.Interop.Forms is not NetOffice,

what i have to do is mark the Object property as non-analyzing property or much better, spend a NetOffice wrapper assembly for Microsoft.Vbe.Interop.Forms. added to todo-list for NO 1.6.1

thanks man for pointing this out!
*Sebastian
Aug 9, 2013 at 9:04 AM
thank you sebastian.

we will use this workaround to acces activex components.
and we will check future releases for fixes.

cheers
roland