How do I set the value of a checkbox

I have a Word document which has checkboxes that I’ve given a tag and a title in the Content Control Properties. Is it possible to target that checkbox and set its value programmatically using GemBox?

Apologies for the lack of code at this stage

Hi Peter,

Try this:

var document = DocumentModel.Load("input.docx");
var tag = "My Tag";

foreach (var contentControl in document.GetChildElements(true,
    ElementType.InlineContentControl,
    ElementType.BlockContentControl))
{
    if (contentControl is InlineContentControl inlineContentControl &&
        inlineContentControl.ContentControlType == ContentControlType.CheckBox &&
        inlineContentControl.Properties.Tag == tag)
    {
        inlineContentControl.Properties.Checked = true;
    }

    if (contentControl is BlockContentControl blockContentControl &&
        blockContentControl.ContentControlType == ContentControlType.CheckBox &&
        blockContentControl.Properties.Tag == tag)
    {
        blockContentControl.Properties.Checked = true;
    }
}

document.Save("output.docx");

Does this solve your issue?

Regards,
Mario

Outstanding thanks so much for getting back to me so promptly, that’s perfect.