JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,027 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The PowerPoint javascript api property PowerPoint.Presentation.customXmlParts returns only part of the custom xml files. For example, all custom xml files saved by SharePoint are missing. Attached Script lab code below.
In attachment is also image showing what custom xml files pptx file includes and what vba code and typescript code shows as the count of customxmlparts.
name: Basic API call (TypeScript)
description: Performs a basic PowerPoint API call using TypeScript.
host: POWERPOINT
api_set: {}
script:
content: >
$("#run").on("click", () => tryCatch(run));
const run: Function = async () => {
// This function gets the collection of shapes on the first slide,
// and adds a text box to the collection, while specifying its text,
// location, and size. Then it names the text box.
await PowerPoint.run(async (context) => {
const customXmlParts = context.presentation.customXmlParts.load();
await context.sync();
console.log(customXmlParts.items.length);
});
};
/** Default helper for invoking an action and handling errors. */
const tryCatch: (callback: Function) => void = async (callback: Function) =>
{
try {
await callback();
} catch (error) {
// Note: In a production add-in, you'd want to notify the user through your add-in's UI.
console.error(error);
}
};
language: typescript
template:
content: |-
<section class="ms-Fabric ms-font-m">
This sample executes a code snippet that customxmlparts count
</section>
<button id="run" class="ms-Button">
<span class="ms-Button-label">show custom xml parts count</span>
</button>
language: html
style:
content: |-
section.samples {
margin-top: 20px;
}
section.samples .ms-Button, section.setup .ms-Button {
display: block;
margin-bottom: 5px;
margin-left: 20px;
min-width: 80px;
}
language: css
libraries: |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
office-ui-fabric-core@11.1.0/dist/css/fabric.min.css
office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css
core-js@2.4.1/client/core.min.js
@types/core-js
jquery@3.1.1
@types/jquery@3.3.1