I am trying to replace the token in the word document with the image i have in base64. But i get an unhelpful error Error Code
Here is the function thats not working
async function insertImage(token, image) {
console.log("adding image");
await Word.run(async (context) => {
const results = context.document.body.search(token);
await context.sync();
results.load();
await context.sync();
console.log(results.items);
for (let i = 0; i < results.items.length; i++) {
const pasteMeHere = results.items[i];
pasteMeHere.insertInlinePictureFromBase64(image, "Replace");
pasteMeHere.delete();
}
await context.sync();
});
}
I have tried different images, one of which from the ms script lab repo which i confirmed working. I have also tried different locations including using the paragraphs.getLast()
function.