79506226

Date: 2025-03-13 10:58:09
Score: 0.5
Natty:
Report link

I think I figured it out - instead of just reading the document's contentControls collection via contentControls = context.document.contentControls; the checkboxes show up when using the getContentControls function:

await Word.run(async (context) => {

const doc = context.document;

let contentControls = context.document.getContentControls({
types: [Word.ContentControlType.checkBox, Word.ContentControlType.richText]
});
contentControls.load("items, tag, type");
await context.sync();

console.log("contentControls:", contentControls);

contentControls.items.forEach(control => {
console.log("Tag:", control.tag, "Type:", control.type);
});

});

Here's the Microsoft documentation for that:
https://learn.microsoft.com/en-us/javascript/api/word/word.document?view=word-js-preview#word-word-document-getcontentcontrols-member(1)

And this was the stackoverflow post that set me on the right track:
Office.js Word API not able to read plain text type content controls

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Whitelisted phrase (-2): I figured it out
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: ak2002