A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
let tracked = [];
let field;
await Word.run(async (context) => {
const selection = context.document.getSelection().getRange();
field = selection.insertField('Start', 'Addin');
field.code = `ADDIN test`;
field.result.insertHtml("<b>Test1</b>", "Start");
await context.sync();
field.code = `ADDIN test1after`
field.track();
field.result.track();
tracked.push(field);
tracked.push(field.result);
await context.sync();
});
await Word.run(tracked, async (context) => {
// NOTE Uncomment to make this work
// let fields = context.document.body.fields.load({ result: { text: true } });
// await context.sync();
// field = fields.items[0];
field.result.insertText("", "Replace");
await context.sync();
// Throws Sorry, something went wrong. Check the OfficeExtension.Error.debugInfo for more information.
});
This certainly used to work before (last tested at the start of June 2024). In our actual extension code I get an even weirder bug down the line with tracked objects, but when attempting to write a reproduction case for it I ran into this simpler issue.
Word Online
This certainly used to work before (last tested at the start of June 2024). In our actual extension code I get an even weirder bug down the line with tracked objects, but when attempting to write a reproduction case for it I ran into this simpler issue.