Search code examples
c#ms-wordcharoffice-interopcpu-word

Determine if checkbox in word document is checked or not - char u0015, microsoft.office.interop.word in c#


Prerequired information

having a word document with the following cell: enter image description here

accessing the cells text like this using Microsoft.Office.Interop.Word:

Document doc = ap.Documents.Open(path, ReadOnly: true, Visible: false);
Table docTable = doc.Tables[1];
string field = table.Rows[12].Cells[2].Range.Text

text result is:

\u0015 will be taken over from employee (wird übernommen von MA)
\u0015 needs to be ordered (muss neu bestellt werden)
\u0015 no need for Laptop/PC (braucht kein Laptop/PC)

Issue

\u0015 is the small checkbox in the word file. But no matter, if the checkbox is checked or not, the char representation is \u0015.

Question

is there any way to determine if the little checkbox from \u0015 no need for Laptop/PC (braucht kein Laptop/PC) is checked or not?


Solution

  • You can use the FormFields property of the Document class to access the controls. Then you can use the CheckBox property which returns a CheckBox object that represents a check box form field.

    ActiveDocument.FormFields(1).CheckBox.Value = False