How to know if Word.docx Check Box (checkboxsymboltype in c# ) is checked or not?

omar wasfi 1 Reputation point
2022-08-12T15:22:27.07+00:00

I have a word document (document.docx) that have more than checkbox.

230660-screen-shot-2022-08-12-at-113102.png

I want to know which one is check.

I can get all the checkboxes in the document by using

using DocumentFormat.OpenXml.Wordprocessing;

WordprocessingDocument documentFormA = WordprocessingDocument.Open(formALocation, true);

var checkBoxs = documentFormA.MainDocumentPart.Document.Body.Descendants<CheckBoxSymbolType>();

But this is the results that I get

230801-screen-shot-2022-08-12-at-112700.png

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,234 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,480 questions
Office Management
Office Management
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Management: The act or process of organizing, handling, directing or controlling something.
2,000 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 112.1K Reputation points
    2022-08-12T17:19:05.29+00:00

    Check if this works:

    bool is_checked = checkBoxs[0] is CheckedState;

    Use another number to verify other checkboxes from this array.

    0 comments No comments