I'm currently working on a function that pulls data from an API to convert PowerPoint presentations into base64 strings. Once I receive the response object, my goal is to seamlessly insert the slides into the existing presentation, exactly after the slide that is currently selected.
The approach I had in mind aligns with the documentation provided: retrieving the ID of the selected slide and utilizing it as the target slide ID. However, when attempting to utilize the getSelectedSlideIndex() function as recommended, I encountered a Rich API Promise error. For more information, refer to: https://learn.microsoft.com/en-us/office/dev/add-ins/powerpoint/add-slides
export async function getImageAsBase64String() {
// Function that calls the API for converting presentations to base64 strings
// ..
const results = await response.json();
await PowerPoint.run(async (context) => {
const selectedID = await getSelectedSlideIndex();
context.presentation.insertSlidesFromBase64(results[0].presentations[0], {
targetSlideId: selectedID,
});
await context.sync();
});
}
Regarding the format required for the selected ID, is there a specific structure or standard to adhere to? The end goal is to enable users to simply select a slide, press a button, and have the new slides (in base64 format) added immediately after the chosen slide.