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


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


$("#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 function(ctx) {
      ctx.presentation.insertSlidesFromBase64(copyBase64, { formatting: "UseDestinationTheme"});
      // "targetSlideId"
      // "sourceSlideIds"

  // read in the file as a data URL so we can parse the base64-encoded string

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