user1108069
user1108069

Reputation: 513

Office.context.document.customXmlParts is undefined

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

Answers (1)

MandytMSFT
MandytMSFT

Reputation: 89

That's because Office.context.document.customXmlParts only supported on word. Pls use Excel.Workbook.customXmlParts instead for Excel Addin

https://learn.microsoft.com/en-us/office/dev/add-ins/reference/requirement-sets/office-add-in-requirement-sets#customxmlparts

Upvotes: 2

Related Questions