How to create checkboxes or radiobuttons in excel sheet using C#?! RRS feed

  • Question

  • Hy,

    I wrote some console application in C# that replaces some placeholders in word document. I used assebly Microsoft.Office.Interop.Word. With that program I parse XML-file and replace placeholders with text or tabel or checkboxes, depending on some attribute value.

    The same without tabel option I wanted to program with excel sheets. I am using assebly Microsoft.Office.Interop.Excel.
    With the next code snippet I managed to add a checkbox in a sheet, but I get some random label, which I can not access to change the caption:
    Microsoft.Office.Interop.Excel.Shape checkBox = worksheet.Shapes.AddFormControl(Microsoft.Office.Interop.Excel.XlFormControl.xlGroupBox, 100, 100, 100 ,100 );

    Is that possible? I googled a lot and found a lot of similar threads without proper answers.
    Would be alternative to try to use visual basic maybe (just guessing)?Please share your experience and opinions... :)



    • Moved by Aleksander Chalabashiev Wednesday, September 9, 2015 7:43 AM Question is in English
    • Moved by Shakti Prasad Mishra Saturday, September 12, 2015 3:31 PM Moving
    • Moved by Shakti Prasad Mishra Saturday, September 12, 2015 3:33 PM Moving to English forum from
    Wednesday, September 9, 2015 6:48 AM


  • Hi Jurij,

    As far as I know, there is no such property we can change the caption for the checkbox added by code above.

    As a workaround, we can modify the caption via the selection. Here is an example for your reference through:

    Set aCheckBox = asheet.Shapes.AddFormControl(xlCheckBox, 100, 100, 50, 20)
    Application.Selection.Characters.Text = "MyCaption"
    Regards & Fei

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, September 14, 2015 5:19 AM