office-jsoffice-js-helpers

insertSlidesFromBase64 Working on Client Powerpoint, But not on Powerpoint for the web


Here is the Code i Used

async function insertPptxFromBase64String(chosenFileBase64) {
   Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, function (asyncResult) {
       try {
         if (asyncResult.status === Office.AsyncResultStatus.Failed) {``
             console.log(asyncResult.error.message);
          } else {
            const selectedSlideID = asyncResult.value.slides[0].id;
            PowerPoint.run(async function(context) {
                context.presentation.insertSlidesFromBase64(chosenFileBase64, {
                    formatting: "UseDestinationTheme",
                    targetSlideId: selectedSlideID + "#"
                 });
                await context.sync();
            });
          }
        }
        catch (error) {
          reject(console.log(error));
        }
      });
}

This code selects the slide id of the current selected slide, and inserts a presentation after that.

It was running perfectly on both platforms, but around a month back, it stopped working for Powerpoint online(powerpoint on the web).It still runs smoothly on Client Powerpoint(Offline Powerpoint)

Here is the error it shows in console

powerpoint-web-16.00.js:26 Uncaught (in promise) RichApi.Error: Cannot read property 'invokePropertySet' of null
    at new n (powerpoint-web-16.00.js:26)
    at n.i.processRequestExecutorResponseMessage (powerpoint-web-16.00.js:26)
    at powerpoint-web-16.00.js:26

Solution

  • Thanks for reporting this - this issue has now been fixed.

    Related Github post: https://github.com/OfficeDev/office-js/issues/2071