Copy PowerPoint shapes using office js to a new slide

47 Views Asked by At

I'm trying to do something which seems simple using office js but I can't get it to work. I am reading a pptx file and inserting the first slide into my presentation with the following:

  //insert new slide from pptx file
  context.presentation.insertSlidesFromBase64(base64file);
  await context.sync();
  context.presentation.slides.load();
  await context.sync();

  //load all the shapes on the new slide
  const slide = context.presentation.slides.getItemAt(0);
  slide.load();
  await context.sync();

After doing this, I want to create these same loaded shapes on a new slide or cut and paste the shapes on to a new slide. I can't see any way to do this. Am I missing something or is this not possible?

I expected there would be a way to clone existing shapes and add them to a different slide but I don't see that is possible. I thought maybe you could add the cloned shapes to the slidecollection of a different slide but that doesn't seem to be possible. What I am trying to achieve is reading in a pptx file with one slide, reading the shapes of that slide and inserting those shapes on the currently selected slide in PowerPoint. The reason for this is that we really want to do is read in multiple PowerPoint files, get all the shapes and put them on one slide, preferably grouping each set of shapes from each selected input PowerPoint file.

Thanks in advance for any assistance.

0

There are 0 best solutions below