Word
A family of Microsoft word processing software products for creating web, email, and print documents.
873 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm new to Office Web Add-Ins (having come from VSTO land), so I'm probably not understanding something small and silly..
I have a document that contains 10 SEQ fields {{SEQ Test * MERGEFORMAT}} . I copied and pasted them, so they all show a result of '1'. I'd like to programmatically refresh them so that they show as '1' through '10'.
Can anyone please tell me what is wrong with my code? Or am I misunderstanding what the UpdateResult function should do?
export async function UpdateAllFields_Click(event: Office.AddinCommands.Event) {
await Word.run(async (context) => {
console.log("UpdateAllFields_Click");
context.document.body.fields.load();
await context.sync();
for (let field of context.document.body.fields.items) {
field.load(["code", "result", "locked", "type", "data", "kind"]);
await context.sync();
console.log(
"Before updating:",
"Code of first field: " + field.code,
"Result of first field: " + JSON.stringify(field.result)
);
field.updateResult();
field.select();
await context.sync();
field.load(["code", "result"]);
await context.sync();
console.log(
"After updating:",
"Code of first field: " + field.code,
"Result of first field: " + JSON.stringify(field.result)
);
}
await context.sync();
});
event.completed();
}