Slides


Inserting a slide from another presentation / external source
Uses the slide ID - this is the same as that available in VBA


HTML

<section class="ms-font-m"> 
  <p>This sample shows how to add slides from an existing presentation,</p>
  </section>
  <section class="samples ms-font-m">
    <p>Select a PowerPoint presentation to insert slides from</p>
    <form>
      <input type="file" id="file" </p>
      </form>
  </section>

Script

$("#file").change( () => tryCatch(useInsertSlidesApi)); 

async function useInsertSlideApi() {
  const myFile = <HTMLInputElement>document.getElementById("file");
  const reader = new FileReader();

  reader.onload = async (event) => {
    // strip off the metadata before the base64-encoded string
    const startIndex = reader.result.toString().indexOf("base64,");
    const copyBase64 = reader.result.toString().substr(startIndex + 7);

    await PowerPoint.run(async function(ctx) {
      ctx.presentation.insertSlidesFromBase64(copyBase64, { formatting: "UseDestinationTheme"});
      // "targetSlideId"
      // "sourceSlideIds"
      ctx.sync();
    });
  };

  // read in the file as a data URL so we can parse the base64-encoded string
  reader.readAsDataURL(myfile.files[0]);
}



© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext