This project has moved and is read-only. For the latest updates, please go here.

Set the value of OptionButton in Excel

Mar 11, 2016 at 1:41 PM
I am trying to set the value of OptionButton in Excel but can't do it.
The code:
Object PCI_no = _myxlWorkSheet.OLEObjects("rob_tabDev_row12_PCI_N");
if (PCI_no != null)
xcel.OptionButton PCI_no1 = (Excel.OptionButton)PCI_no;
PCI_no1.Value = false;

When use Microsoft.Office.Interop.Excel
I can do it like this:
var PCI_no = _myxlWorkSheet.OLEObjects("rob_tabDev_row12_PCI_N").Object;
if (PCI_no!=null)
          PCI_no.Value = false;
How can i do it in NetOffice?
Please HELP!
Aug 19, 2016 at 10:00 PM

I have similar question, I would use this to set my checkbox value:-
         xlWorkSheet.OLEObjects("CheckBox1").Object.Value = false;
How do you set the value in netoffice?

Aug 20, 2016 at 12:11 AM
The current release doesnt handle external references as well. (And OLE is external stuff)
As hotfix i try to suggest you to use the Invoker to call them trough late binding.

The upcoming NO release want handle this better(specialy in Visuak Basic) - coming next weekend - i hope so.

BTW; any exception details is greatly appreciated.
Sep 6, 2016 at 8:13 PM
Sorry about the delay in responding, was on vacation. I know this line for instance as found my checkbox:-

Excel.OLEObject oleObjects = (Excel.OLEObject)xlWorkSheet.OLEObjects("CheckBox1");

and oleObjects then as a whole bunch of properties (visible, width, height etc. etc.) that I can affect it with but it does not have one for value.

So can you give me an example using Invoker to change the Value property?

Sep 6, 2016 at 9:04 PM
Ok Ive figured it out:-
            Excel.OLEObject oleObjects = (Excel.OLEObject)xlWorkSheet.OLEObjects("CheckBox1");
            Excel.CheckBox CheckBox1 =  (Excel.CheckBox)oleObjects.Object;
            CheckBox1.Value = false;
This works fine now.
Sep 6, 2016 at 9:18 PM
BTW: There is a special library called Forms 2.0 .The buttons, textboxes, labels from the integretaded VBA designer(VBEIDE)
NetOffice spend an individual wrapper library here, just include them to your solution.
(Use it or loose it)