How to insert slide from one presentation to another?

Hi! Is there any way to insert (copy) slide from one presentation to another? I’m creating plugin for desktop editor.
I have one ‘template’ presentation (i know file path/pptx file data) and want to insert several slides (e.g. first slide) to the current presentation.

Sample scenario:

  1. user opens some presentation
  2. user opens plugin
  3. plugin inserts slides to the current presentation from predefined template presentation (for the first time it will be downloaded file from server in pptx format)

Hello @scoolnik
We thought about similar case (‘insert slide from one presentation to another’), but in different way. We’re planning to implement copy\paste slides between presentations in a drag’n’drop way. Please clarify if it is what you are looking for. Or do you want to achieve slide copy feature between presentation via some sort of plugin?

Hello.
I want to achieve slide copy feature between presentation via plugin. Not sure if ‘a drag’n’drop way’ is an option for my case, but it sounds quite interesting.
For example, in PowerPoint there is an option to load presentation as an Object and do some operations with it (similar to ONLYOFFICE Document Builder, but on ‘client’ side)

Could you please point me to this feature on MS PowerPoint? We will check it out. As far as I understand you want to achieve the same behavior with our editor.

Sure. Here some docs:

And code example (C#):

string templatePath = "C:/exampleFolder/presentation.pptx";
Application app = Globals.ThisAddIn.Application;

Presentation template = app.Presentations.Open(templatePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
Presentation currentPresentation = app.ActiveWindow.Presentation;

int selectedSlideNumber = app.ActiveWindow.Selection.SlideRange[1].SlideNumber;
int slideToCopyNumber = 3;
                    
template.Slides[slideToCopyNumber].Copy(); //copies to clipboard, not really good api
                    
Slide slide = currentPresentation.Slides.Paste()[1];
slide.MoveTo(selectedSlideNumber + 1);
					
template.Close();

Thank you for provided details. We need some time to check it out, I will update this thread when we have something to share.

1 Like

Hello @scoolnik
Sorry for the late reply. Probably you can achieve the desired result by converting Slide object to json and back:

1 Like