I have an application which identify some slides with some criteria and want to copy those slides to a single PPTX file. I have openxml code for copy slides and it working perfectly but taking too much time when output file size increases. So i decided to move to interop for coping. Following code is for coping slide.
using Microsoft.Office.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PowerPoint=Microsoft.Office.Interop.PowerPoint;
namespace CloneSlide{classProgram{staticvoidMain(string[] args){try{PowerPoint.Application app =newPowerPoint.Application();PowerPoint.Presentation currPresentation =null;PowerPoint.Presentation currPresentationop =null;string inputFileName =@"C:\Users\user\Desktop\Blannkdocs\ppt\Input.pptx";//PowerPoint.Presentations presentations = app.Presentations;//var readOnly = Microsoft.Office.Core.MsoTriState.msoTrue;//var untitled = Microsoft.Office.Core.MsoTriState.msoTrue;//var withwindow = Microsoft.Office.Core.MsoTriState.msoFalse;//string chkfileforpassword = inputFileName + "::" + "\"\"" + "::" + "\"\"";//currPresentation = presentations.Open(chkfileforpassword, readOnly, untitled, withwindow);//currPresentation.Slides[1].Copy();string outputFileName =@"C:\Users\user\Desktop\Blannkdocs\ppt\Presentation1.pptx";PowerPoint.Presentations presentationsop = app.Presentations;
currPresentationop = presentationsop.Open(outputFileName,MsoTriState.msoFalse,MsoTriState.msoFalse,MsoTriState.msoFalse);//currPresentationop.Slides.Paste(1);
currPresentationop.Slides.InsertFromFile(inputFileName,1,1,1);System.Threading.Thread.Sleep(4000);
currPresentationop.Save();
app.Quit();}catch(Exception exp){Console.WriteLine(exp);}Console.WriteLine("Execution Complete");Console.ReadLine();}}}
I have already tried with
//currPresentationop.Slides.Paste(1);
currPresentationop.Slides.InsertFromFile(inputFileName,1,1,1);
in both the case content are copied but the background and formatting of the slides were disappeared in the output. Is there anything I missed to add while coping.