$("#number").on("click", () => tryCatch(insertNumericProperty));
$("#string").on("click", () => tryCatch(insertStringProperty));
$("#read").on("click", () => tryCatch(readCustomDocumentProperties));
async function insertNumericProperty() {
await Word.run(async (context) => {
context.document.properties.customProperties.add("Numeric Property", 1234);
await context.sync();
console.log("Property added");
});
}
async function insertStringProperty() {
await Word.run(async (context) => {
context.document.properties.customProperties.add("String Property", "Hello World!")
;
await context.sync();
console.log("Property added");
});
}
async function readCustomDocumentProperties() {
await Word.run(async (context) => {
const properties: Word.CustomPropertyCollection =
context.document.properties.customProperties;