Reputation: 513
I'm working on an Excel addin using Office JS, in a taskpane, I call Office.context.document.customXmlParts.getByNamespaceAsync, but it throws exception 'TypeError: Cannot read property 'getByNamespaceAsync' of undefined', namely Office.context.document.customXmlParts is undefined
The office-js version is 1.0.52
The below way to get the customXmlParts works:
return await Excel.run(async ctx => {
const workbook = ctx.workbook;
workbook.load("customXmlParts");
await ctx.sync();
const items = workbook.customXmlParts.items;
...
}
But I need to call getByNamespaceAsync to use the Office.CustomXmlPart.value.addHandlerAsync in the callback, so the above way doesn't suit.
Any idea please?
Upvotes: 0
Views: 564
Reputation: 89
That's because Office.context.document.customXmlParts only supported on word. Pls use Excel.Workbook.customXmlParts instead for Excel Addin
Upvotes: 2