public override void Convert(String inputFile, String outputFile)
        {
            try
            {
                if (!File.Exists(inputFile))
                {
                    throw new ConvertException("File not Exists");
                }

                if (IsPasswordProtected(inputFile))
                {
                    throw new ConvertException("Password Exist");
                }

                app = new PowerPoint.Application();
                presentations = app.Presentations;
                presentation = presentations.Open(inputFile, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
                presentation.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF);
                // presentation.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF, PowerPoint.PpFixedFormatIntent.ppFixedFormatIntentScreen, MsoTriState.msoFalse, PowerPoint.PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, PowerPoint.PpPrintOutputType.ppPrintOutputSlides, MsoTriState.msoFalse, null, PowerPoint.PpPrintRangeType.ppPrintAll, "", false, false, false, false, false, null);
            }
            catch (Exception e)
            {
                release();
                throw new ConvertException(e.Message);
            }
            release();
        }
 private void OpenPresentation()
 {
     _application   = new PowerPoint.Application();
     _presentations = _application.Presentations;
     GC.Collect();
     if (_ReadOnly)
     {
         _presentation = _presentations.Open(FilePath, MsoTriState.msoCTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
     }
     else
     {
         _presentation = _presentations.Open(FilePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
     }
 }
        private void Form2_Load(object sender, EventArgs e)
        {
            string fileName   = @"C:\Users\Tridip\Desktop\KPIDashBoard20170125 125513.pptx";
            string exportName = "video_of_presentation";
            string exportPath = @"D:\test\Export\{0}.wmv";

            Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
            ppApp.Visible     = Microsoft.Office.Core.MsoTriState.msoTrue;
            ppApp.WindowState = PpWindowState.ppWindowMinimized;
            Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = ppApp.Presentations;
            Microsoft.Office.Interop.PowerPoint._Presentation oPres    = oPresSet.Open(fileName,
                                                                                       Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                                       Microsoft.Office.Core.MsoTriState.msoFalse);
            try
            {
                //oPres.CreateVideo(exportName);
                oPres.SaveCopyAs(String.Format(exportPath, exportName),
                                 Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsEMF,
                                 Microsoft.Office.Core.MsoTriState.msoCTrue);
            }
            finally
            {
                ppApp.Quit();
            }
        }
Beispiel #4
0
        public void CopySlide(string str, Boolean worship)
        {
            string filePath = "";

            if (worship)
            {
                filePath = InnerBox.ListRoot + "\\" + "찬양집" + "\\" + str;
            }
            else
            {
                filePath = InnerBox.ListRoot + "\\" + "새찬송가" + "\\" + str;
            }

            PowerPoint.Application   CurrentApplication = Globals.ThisAddIn.Application;
            PowerPoint.Presentations currentPTs         = CurrentApplication.Presentations;
            PowerPoint.Presentation  currentPT          = CurrentApplication.ActivePresentation;
            PowerPoint.Presentation  copyPT             = currentPTs.Open(filePath, Core.MsoTriState.msoTrue, Core.MsoTriState.msoTrue, Core.MsoTriState.msoFalse);

            for (var i = 1; i <= copyPT.Slides.Count; i++)
            {
                copyPT.Slides[i].Copy();
                currentPT.Slides.Paste(currentPT.Slides.Count + 1).Design = copyPT.Slides[i].Design;
                currentPT.Slides[currentPT.Slides.Count].Shapes.Title.TextFrame.TextRange.Font.NameFarEast = "나눔고딕";
                currentPT.Slides[currentPT.Slides.Count].Shapes[1].TextFrame.TextRange.Font.NameFarEast    = "나눔고딕";
            }
        }
        private void DeleteSlide(int index)
        {
            //TODO: try-catch
            PPT.Application   app  = new PPT.Application();
            PPT.Presentations pres = app.Presentations;

            PPT.Presentation pptx = pres.Open(LibraryFile.FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);

            PPT.Slides slides = pptx.Slides;
            PPT.Slide  slide  = slides[index];

            slide.Delete();

            pptx.Save();
            pptx.Close();

            slide.ReleaseCOM();
            slide = null;

            slides.ReleaseCOM();
            slides = null;

            pptx.ReleaseCOM();
            pptx = null;

            pres.ReleaseCOM();
            pres = null;

            app.ReleaseCOM();
            app = null;
        }
Beispiel #6
0
        /// <summary>
        /// Opens Presentation and selects slide
        /// </summary>
        /// <param name="path"></param>
        /// <param name="slideIndex"></param>
        private void OpenPresentation(string path, int slideIndex = 1)
        {
            PPT.Application   ppt             = null;
            PPT.Presentations pres            = null;
            PPT.Presentation  pptPresentation = null;

            try
            {
                ppt  = new PPT.Application();
                pres = ppt.Presentations;

                //TODO: Check if file is already opned
                pptPresentation = pres.Open(path);
                pptPresentation.Slides[slideIndex].Select();
            }
            catch (Exception)
            {
            }
            finally
            {
                pptPresentation.ReleaseCOM();
                pptPresentation = null;

                pres.ReleaseCOM();
                pres = null;

                ppt.ReleaseCOM();
                ppt = null;
            }
        }
Beispiel #7
0
 public void PptAction(PptDetails pptDetails)
 {
     pptDetailsMain = pptDetails;
     DodoMediaPlayer.Stop();
     this.Hide();
     if (pptDetails != null)
     {
         try
         {
             //Create a new presentation based on a template.
             objApp = new powerpointinterop.Application();
             //  objApp.SlideShowBegin += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowBeginEventHandler(powerpnt_SlideShowBegin);
             objApp.SlideShowEnd += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowEndEventHandler(powerpnt_SlideShowEnd);
             //objApp.SlideShowNextSlide += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowNextSlideEventHandler(powerpnt_SlideShowNextSlide);
             objApp.Visible = MsoTriState.msoTrue;
             objPresSet     = objApp.Presentations;
             string pptName = pptDetails.Name;
             string pptPath = System.IO.Path.Combine(Mocker.debugPath, "Ppts", pptName);
             objPres   = objPresSet.Open(pptPath, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoTrue);
             objSlides = objPres.Slides;
             objSSS    = objPres.SlideShowSettings;
             objSSS.Run();
         }
         catch (Exception)
         {
         }
     }
     else
     {
         MessageBox.Show("Media Not Found");
     }
 }
        public override void Convert(String inputFile, String outputFile)
        {
            try
            {
                if (!File.Exists(inputFile))
                {
                    throw new ConvertException("File not Exists");
                }

                if (IsPasswordProtected(inputFile))
                {
                    throw new ConvertException("Password Exist");
                }

                app           = new PowerPoint.Application();
                presentations = app.Presentations;
                presentation  = presentations.Open(inputFile, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
                presentation.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF);
                // presentation.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF, PowerPoint.PpFixedFormatIntent.ppFixedFormatIntentScreen, MsoTriState.msoFalse, PowerPoint.PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, PowerPoint.PpPrintOutputType.ppPrintOutputSlides, MsoTriState.msoFalse, null, PowerPoint.PpPrintRangeType.ppPrintAll, "", false, false, false, false, false, null);
            }
            catch (Exception e)
            {
                release();
                throw new ConvertException(e.Message);
            }
            release();
        }
        private void ReadSlide(object sender, EventArgs e)
        {
            if (NoPowerPoint())
            {
                ofd = new OpenFileDialog {
                    Filter = powerpointformat
                };
                try
                { if (ofd.ShowDialog() == DialogResult.OK)
                  {
                      file_path = ofd.FileName;
                  }
                  else
                  {
                      return;
                  } } catch (SystemException exc)
                { MessageBox.Show(open_err_msg + ofd.FileName + ":\n\n" + exc);
                  return; } finally { ofd.Dispose(); }

                PowerPoint_App      = new Ppt.Application();
                multi_presentations = PowerPoint_App.Presentations;
                presentation        = multi_presentations.Open(file_path, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);
            }

            TitleBox.Text    = string.Empty;
            BodyTextBox.Text = string.Empty;
            layout           = Active_slide.Layout;

            if (layout == Ppt.PpSlideLayout.ppLayoutText)
            {
                TitleBox.Text    = Active_slide.Shapes[1].TextFrame.TextRange.Text;
                BodyTextBox.Text = Active_slide.Shapes[2].TextFrame.TextRange.Text;
            }
            else
            {
                foreach (var item in presentation.Slides[1].Shapes)
                {
                    var shape = (Ppt.Shape)item;
                    if (shape.HasTextFrame != MsoTriState.msoTrue)
                    {
                        continue;
                    }

                    if (shape.Name.Contains("Title"))
                    {
                        TitleBox.Text += shape.TextFrame.TextRange.Text + ' ';
                        box_list.Insert(0, shape.Name);
                    }

                    else if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                    {
                        IDataObject clipped = Clipboard.GetDataObject();
                        shape.TextFrame.TextRange.Copy();
                        BodyTextBox.Paste();
                        Clipboard.SetDataObject(clipped, true);
                        box_list.Add(shape.Name);
                    }
                }
            }
        }
Beispiel #10
0
 public void replaceContent(List <Segment> segments, string path)
 {
     Microsoft.Office.Interop.PowerPoint.Application   application         = new Microsoft.Office.Interop.PowerPoint.Application();
     Microsoft.Office.Interop.PowerPoint.Application   pwpApp              = new Microsoft.Office.Interop.PowerPoint.Application();
     Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = pwpApp.Presentations;
     Microsoft.Office.Interop.PowerPoint.Presentation  presentation        = multi_presentations.Open(path, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
     try
     {
         foreach (Segment segment in segments)
         {
             int    shape  = segment.shape;
             int    slide  = segment.slide;
             string source = segment.getTMSource();
             string target = segment.getTMTarget();
             if (!string.IsNullOrEmpty(target))
             {
                 Microsoft.Office.Interop.PowerPoint.TextRange textRange = presentation.Slides[slide].Shapes[shape].TextFrame.TextRange;
                 textRange.Replace(source, target, 0, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
             }
         }
         presentation.Save();
         presentation.Close();
         pwpApp.Quit();
     }
     catch (Exception ex)
     {
         presentation.Save();
         presentation.Close();
         pwpApp.Quit();
         File.Delete(path);
     }
 }
Beispiel #11
0
 /// <summary>
 /// 打开被选中的幻灯片
 /// </summary>
 /// <param name="strTemplate"></param>
 private void ShowPresentation(string strTemplate)
 {
     objApp         = new PowerPoint.Application();
     objApp.Visible = MsoTriState.msoTrue;
     objPresSet     = objApp.Presentations;
     objPres        = objPresSet.Open(strTemplate,
                                      MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
     objSlides = objPres.Slides;
 }
Beispiel #12
0
        internal List <string> Export()
        {
            var contents = new List <string>();

            using (var ppt = new ComWrapper <PowerPoint.Presentation>(
                       ppts.Open(file,
                                 ReadOnly: Microsoft.Office.Core.MsoTriState.msoTrue,
                                 WithWindow: Microsoft.Office.Core.MsoTriState.msoFalse)
                       ))
            {
                var tempFiles = new string[2];
                var success   = false;
                try
                {
                    tempFiles[0] = Path.GetTempFileName();
                    tempFiles[1] = Path.GetTempFileName();

                    //Text in PPT
                    //Save as rich text file.
                    ppt.ComObject.SaveAs(tempFiles[0], FileFormat: PowerPoint.PpSaveAsFileType.ppSaveAsRTF);
                    //Read and save as a text file.
                    string richText = File.ReadAllText(tempFiles[0], Encoding.Default);
                    //Cheep trick to convert text from rtf.
                    RichTextBox richTextBox = new RichTextBox();
                    richTextBox.Rtf = richText;
                    File.WriteAllText(tempFiles[0], richTextBox.Text, Encoding.Default);

                    //Text in shapes & comments
                    var slideContents = new List <string>();
                    foreach (PowerPoint.Slide slide in ppt.ComObject.Slides)
                    {
                        foreach (PowerPoint.Shape shape in slide.Shapes)
                        {
                            ExtractShapeContents(slideContents, shape);
                        }
                        foreach (PowerPoint.Comment comment in slide.Comments)
                        {
                            slideContents.Add(comment.Author + ":" + comment.Text);
                        }
                        slideContents.Add(slide.NotesPage.Shapes.Placeholders[2].TextFrame.TextRange.Text);//placefolders[1] is slide itself.
                    }
                    File.WriteAllLines(tempFiles[1], slideContents, Encoding.Default);
                    success = true;
                }
                finally
                {
                    ppt.ComObject.Close();
                    //merge contents after closing ppt.
                    if (success)
                    {
                        contents = FileUtils.MergeTextContents(tempFiles);
                    }
                    FileUtils.DeleteFiles(tempFiles);
                }
                return(contents);
            }
        }
Beispiel #13
0
        private string ConvertPowerPoint(string FilePath)
        {
            try
            {
                // new object
                //objPP = new Microsoft.Office.Interop.PowerPoint.Application();
                //var objPresentation = objPP.ActivePresentation;

                // get file name
                string[] file         = FilePath.Split('\\');
                string   FullFileName = file[file.Length - 1];
                // get extension
                string[] splittedFile = FullFileName.Split('.');
                string   ext          = splittedFile[splittedFile.Length - 1].ToUpper();
                string   filename     = splittedFile[splittedFile.Length - 2].ToUpper();


                // get convert folder directory
                string convertFolder = ConfigurationManager.AppSettings["ProjectHTMLRoot"];
                object target        = HttpContext.Current.Server.MapPath(convertFolder) + GetConvertPath(FilePath) + filename + ".htm";
                object source        = FilePath;


                if (ext == "PPT" || ext == "PPTX")
                {
                    //open the file internally in word. In the method all the parameters should be passed by object reference
                    string i = source.ToString();

                    objPP = new Microsoft.Office.Interop.PowerPoint.Application();
                    objPP.DisplayAlerts = PpAlertLevel.ppAlertsNone;
                    Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = objPP.Presentations;
                    Microsoft.Office.Interop.PowerPoint._Presentation oPres    = oPresSet.Open(FilePath,
                                                                                               Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                                               Microsoft.Office.Core.MsoTriState.msoFalse);
                    string t = target.ToString();
                    oPres.SaveAs(t, PpSaveAsFileType.ppSaveAsHTMLv3, Microsoft.Office.Core.MsoTriState.msoTrue);

                    return("../" + convertFolder + "/" + filename + ".htm");
                }
                else
                {
                    return("");
                }
            }
            catch
            {
                throw new Exception();
            }
            finally
            {
                //Close/quit word
                //objPres.Close();
                objPP.Quit();
                Marshal.ReleaseComObject(objPP);
            }
        }
Beispiel #14
0
        public List <IFileItem> AppendShapes(List <PPT.Shape> srcShapes)
        {
            PPT.Application   ppt             = null;
            PPT.Presentations pres            = null;
            PPT.Presentation  pptPresentation = null;
            try
            {
                ppt  = new PPT.Application();
                pres = ppt.Presentations;

                pptPresentation = pres.Open(FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);

                PPT.DocumentWindow wnd = pptPresentation.Windows[1];
                //wnd.Height = 200;
                //wnd.Top = -200;
                wnd.WindowState = PPT.PpWindowState.ppWindowMinimized;
                wnd             = null;

                PPT.Slides gSlides    = pptPresentation.Slides;
                int        startIndex = gSlides.Count + 1;
                int        count      = 0;
                foreach (PPT.Shape shape in srcShapes)
                {
                    PPT.Slide slide = gSlides.Add(startIndex + count++, PPT.PpSlideLayout.ppLayoutBlank);
                    shape.Copy();
                    slide.Shapes.Paste();
                    slide.Tags.Add(ShapeTag.Tag, ShapeTag.Value);

                    slide.ReleaseCOM();
                    slide = null;
                }
                List <IFileItem> newItems = new List <IFileItem>();
                newItems = fileIndex.UpdateIndex(pptPresentation, startIndex);

                return(newItems);
            }
            finally
            {
                if (pptPresentation != null)
                {
                    pptPresentation.Save();
                    pptPresentation.Close();
                }
                pptPresentation.ReleaseCOM();
                pptPresentation = null;

                pres.ReleaseCOM();
                pres = null;

                ppt.ReleaseCOM();
                ppt = null;
            }
        }
Beispiel #15
0
        public void CreateNewPPT()
        {
            application        = new PowerPoint.Application();
            pptPresentationSet = application.Presentations;
            pptPresentation    = pptPresentationSet.Open(_fileName, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            //customLayout = pptPresentationSet.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];
            pptSlides = pptPresentation.Slides;
            pptSlide  = pptSlides.AddSlide(1, customLayout);

            textRng           = pptSlide.Shapes[1].TextFrame.TextRange;
            textRng.Font.Name = textDefaultFontName;
            textRng.Font.Size = textDefaultFontSize;
        }
Beispiel #16
0
        private static void GenerateVideoFromPowerPoint()
        {
            var pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();

            Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = pptApplication.Presentations;
            Microsoft.Office.Interop.PowerPoint._Presentation oPres    =
                oPresSet.Open(@"C:\SCBBR53W26C036262\2006 Bentley Continental Fly.pptx",
                              Microsoft.Office.Core.MsoTriState.msoFalse,
                              Microsoft.Office.Core.MsoTriState.msoFalse,
                              Microsoft.Office.Core.MsoTriState.msoTrue);

            string movie = @"C:\SCBBR53W26C036262\2006 Bentley Continental Fly.wmv";

            oPres.CreateVideo(movie, true, 4, 480, 30, 100);
        }
Beispiel #17
0
        public override void ConfigureRendering()
        {
            try
            {
                width  = dpi * 10;
                height = Convert.ToInt32(dpi * 7.5);

                oPowerPoint = new PowerPoint.Application();                                                                                        //запускаем приложение
                oPres       = oPowerPoint.Presentations;                                                                                           //презентации
                oPre        = oPres.Open(presentationPath, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse); //открываем презентацию
                oSlides     = oPre.Slides;                                                                                                         //считываем слайды
                count       = oPre.Slides.Count;
            }
            catch (DirectoryNotFoundException)
            {
                //УВЕДОМЛЕНИЕ О ТОМ, ЧТО ПУТЬ УКАЗАН НЕВЕРНО
                return;
            }
        }
Beispiel #18
0
        public string Read()
        {
            try
            {
                powerPointApp         = new PowerPoint.Application();
                powerPointApp.Visible = MsoTriState.msoFalse;
                multiPresentations    = powerPointApp.Presentations;

                MsoTriState trueState  = MsoTriState.msoTrue;
                MsoTriState falseState = MsoTriState.msoFalse;
                string      filePath   = (string)FilePath;

                presentation = multiPresentations.Open(filePath,
                                                       trueState,
                                                       falseState,
                                                       falseState);

                string result = string.Empty;

                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    foreach (var item in presentation.Slides[i + 1].Shapes)
                    {
                        var shape = (PowerPoint.Shape)item;
                        if (shape.HasTextFrame == MsoTriState.msoTrue && shape.TextFrame.HasText == MsoTriState.msoTrue)
                        {
                            var textRange = shape.TextFrame.TextRange;
                            result += textRange.Text;
                        }
                    }
                }

                powerPointApp.Quit();

                return(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #19
0
        public override string Read()
        {
            try
            {
                powerPointApp = new PowerPoint.Application();
                powerPointApp.Visible = MsoTriState.msoFalse;
                multiPresentations = powerPointApp.Presentations;

                MsoTriState trueState = MsoTriState.msoTrue;
                MsoTriState falseState = MsoTriState.msoFalse;
                string filePath = (string)FilePath;

                presentation = multiPresentations.Open(filePath,
                                                       trueState,
                                                       falseState,
                                                       falseState);

                string result = string.Empty;

                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    foreach (var item in presentation.Slides[i + 1].Shapes)
                    {
                        var shape = (PowerPoint.Shape)item;
                        if (shape.HasTextFrame == MsoTriState.msoTrue && shape.TextFrame.HasText == MsoTriState.msoTrue)
                        {
                            var textRange = shape.TextFrame.TextRange;
                            result += textRange.Text;
                        }
                    }
                }

                powerPointApp.Quit();

                return result;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #20
0
        private bool LoadPresentation()
        {
            ofd = new OpenFileDialog {
                Filter = powerpointformat
            };
            try
            { if (ofd.ShowDialog() == DialogResult.OK)
              {
                  file_path = ofd.FileName;
              }
              else
              {
                  return(false);
              } } catch (SystemException exc)
            { MessageBox.Show(open_err_msg + ofd.FileName + ":\n\n" + exc);
              return(false); } finally { ofd.Dispose(); }

            presentation = presentation_list.Open(file_path, msoFalse, msoFalse, msoTrue);
            ChangeButtons();
            return(true);
        }
Beispiel #21
0
 public void StartPresentation()
 {
     try
     {
         LaunchApplication();
         g_PPT_CurrentPresentations      = g_PPT_Application.Presentations;
         g_PPT_PresentationToBeProjected = g_PPT_CurrentPresentations.Open(g_PPT_FileLocation, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.StartingSlide = 1;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowWithAnimation = MsoTriState.msoTrue;
         g_PPT_PresentationToBeProjected.SlideShowSettings.Run();
         g_PPT_Application.PresentationClose += g_PPT_Application_PresentationClose;
         //g_PPT_Application.Activate();
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         //Do nothing
     }
 }
Beispiel #22
0
 public void StartPresentation()
 {
     try
     {
         LaunchApplication();
         g_PPT_CurrentPresentations = g_PPT_Application.Presentations;
         g_PPT_PresentationToBeProjected = g_PPT_CurrentPresentations.Open(g_PPT_FileLocation, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.StartingSlide = 1;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings;
         //g_PPT_PresentationToBeProjected.SlideShowSettings.ShowWithAnimation = MsoTriState.msoTrue;
         g_PPT_PresentationToBeProjected.SlideShowSettings.Run();
         g_PPT_Application.PresentationClose += g_PPT_Application_PresentationClose;
         //g_PPT_Application.Activate();
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         //Do nothing
     }
 }
Beispiel #23
0
        void showPowerpoint()
        {
            pptApp = new Microsoft.Office.Interop.PowerPoint.Application();
            var directory = new DirectoryInfo(fileLocationTxt.Text);
            var myFile    = directory.GetFiles()
                            .OrderByDescending(f => f.LastWriteTime)
                            .First();
            string path = Path.Combine(myFile.Directory.FullName, myFile.Name);

            pptApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
            pptApp.Activate();

            ps = pptApp.Presentations;
            try
            {
                p = ps.Open(path,
                            Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);

                pptApp.ActivePresentation.SlideShowSettings.Run();
            }
            catch { }
        }
Beispiel #24
0
        private bool GenerateVideoFromPowerPoint(DealerViewModel dealer, CarShortViewModel car)
        {
            try
            {
                var sourcePath     = (ConfigurationHandler.DealerImages + "/" + dealer.DealerId + "/" + car.Vin + "/NormalSizeImages");
                var pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = pptApplication.Presentations;
                Microsoft.Office.Interop.PowerPoint._Presentation oPres    =
                    oPresSet.Open(sourcePath + String.Format(@"\{0} {1} {2} {3}.pptx", car.ModelYear, car.Make, car.Model, car.Trim),
                                  Microsoft.Office.Core.MsoTriState.msoFalse,
                                  Microsoft.Office.Core.MsoTriState.msoFalse,
                                  Microsoft.Office.Core.MsoTriState.msoTrue);

                string movie = sourcePath + String.Format(@"\{0} {1} {2} {3}.wmv", car.ModelYear, car.Make, car.Model, car.Trim);
                oPres.CreateVideo(movie, true, 4, 480, 30, 100);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Создать файл презентации
        /// </summary>
        /// <param name="ppFilePath">Полный путь к файлу с презентацией</param>
        /// <param name="pptFiledbId">id презентации в БД</param>
        /// <param name="archivePath">Полный путь к архиву, содержащему презентацию ()</param>
        public PPTFile(string ppFilePath, long pptFiledbId, string archivePath = null)
        {
            Microsoft.Office.Interop.PowerPoint._Application  powerPointApp   = new Microsoft.Office.Interop.PowerPoint.Application();
            Microsoft.Office.Interop.PowerPoint.Presentations ppPresentations = powerPointApp.Presentations;
            _Presentation = ppPresentations.Open(ppFilePath, MsoTriState.msoCTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);

            if (archivePath == null)
            {
                _PresentationInfo = new PresentationInfo(ppFilePath)
                {
                    SlidersInfo = new List <SlideInfo>(), DbId = pptFiledbId
                }
            }
            ;
            else
            {
                _PresentationInfo = new PresentationInfo(archivePath)
                {
                    SlidersInfo = new List <SlideInfo>(), DbId = pptFiledbId
                }
            };
        }
Beispiel #26
0
        /// <summary>
        /// Constructor that creates the PowerPoint object, so that we can add slides to it
        /// </summary>
        public Powerpoint()
        {
            String strTemplate;
            strTemplate = Constant.ePath + "eFlash.pot";
            //strTemplate = "C:\\Program Files\\eFlash\\Data\\Media\\" + "blank.pot";

            //Create a new presentation based on a template.
            objApp = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet = objApp.Presentations;
            objPres = objPresSet.Open(strTemplate,
                MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            objSlides = objPres.Slides;

            //Prevent Office Assistant from displaying alert messages:
            bAssistantOn = objApp.Assistant.On;
            objApp.Assistant.On = false;

            //start sCount at 1
            sCount = 1;
            oCount = 1;
        }
Beispiel #27
0
        /// <summary>
        ///  Start presentation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            Choices sList = new Choices();

            sList.Add(new string[] { "Next slide", "Previous slide", "Hey presentation you can exit now" });
            Grammar gr = new Grammar(new GrammarBuilder(sList));

            try
            {
                sRecognize.RequestRecognizerUpdate();
                sRecognize.LoadGrammar(gr);
                sRecognize.SpeechRecognized += sRecognize_SpeechRecognized;
                sRecognize.SetInputToDefaultAudioDevice();
                sRecognize.RecognizeAsync(RecognizeMode.Multiple);
                sRecognize.Recognize();
            }

            catch
            {
                //return;  // comment this to avoid unnecessarry exiting.
            }

            if (ppt_file.Text.Equals(""))
            {
                MessageBox.Show("No PowerPoint file selected",
                                "PPT Viewer", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                objPres = objPresSet.Open(ppt_file.Text,
                                          MsoTriState.msoFalse, MsoTriState.msoTrue,
                                          MsoTriState.msoTrue);
                objPres.SlideShowSettings.Run();
                this.WindowState = FormWindowState.Minimized;
                showRunning      = true;
            }
        }
Beispiel #28
0
        /// <summary>
        /// Constructor that creates the PowerPoint object, so that we can add slides to it
        /// </summary>
        public Powerpoint()
        {
            String strTemplate;

            strTemplate = Constant.ePath + "eFlash.pot";
            //strTemplate = "C:\\Program Files\\eFlash\\Data\\Media\\" + "blank.pot";

            //Create a new presentation based on a template.
            objApp         = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet     = objApp.Presentations;
            objPres        = objPresSet.Open(strTemplate,
                                             MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            objSlides = objPres.Slides;

            //Prevent Office Assistant from displaying alert messages:
            bAssistantOn        = objApp.Assistant.On;
            objApp.Assistant.On = false;

            //start sCount at 1
            sCount = 1;
            oCount = 1;
        }
        /// <summary>
        /// Scans pptx file and creates Index
        /// </summary>
        public void CreateIndex()
        {
            items.Clear();

            DeleteIndexFile();
            CreateIndexFile();

            PPT.Application   app          = null;
            PPT.Presentations preentations = null;
            PPT.Presentation  pptx         = null;
            try
            {
                app          = new PPT.Application();
                preentations = app.Presentations;
                pptx         = preentations.Open(LibraryFile.FullPath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
//                PPT.Slides gSlides = pptx.Slides;

                UpdateIndex(pptx, 1);
            }
            catch (Exception ex)
            {
                DeleteIndexFile();
                throw ex;
            }
            finally
            {
                pptx?.Close();
                pptx.ReleaseCOM();
                pptx = null;

                preentations.ReleaseCOM();
                preentations = null;

                app.ReleaseCOM();
                app = null;
            }
        }
Beispiel #30
0
        public override void Convert(string inputFile, string outputFile)
        {
            if (!File.Exists(inputFile))
            {
                throw new ConvertException("文件不存在!");
            }

            try
            {
                // 打开文档
                PowerPoint.Presentation ppt = _ppts.Open(inputFile, WithWindow: Microsoft.Office.Core.MsoTriState.msoFalse);

                // 转换文档
                ppt.ExportAsFixedFormat(outputFile, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF);

                // 关闭文档
                Close(ppt);
            }
            catch (Exception e)
            {
                // 打开、转换文档失败
                throw new ConvertException(e);
            }
        }
Beispiel #31
0
        public void RunPPTMacro(string pptFileName, string excelFile, string macro, bool visible)
        {
            //### improve & cleanup code

            // Define Workbooks
            PowerPoint.Application   oPP         = null;
            PowerPoint.Presentations oPresSet    = null;
            PowerPoint._Presentation _activePres = null;
            object oMissing = System.Reflection.Missing.Value;

            string mess = "";

            try
            {
                //open Excel
                //System.Diagnostics.Process excelProc = System.Diagnostics.Process.Start(excelFile);

                Excel2.Application oExcel = new Excel2.Application();
                oExcel.Visible       = false;
                oExcel.DisplayAlerts = false;
                Excel2.Workbooks oBooks = oExcel.Workbooks;
                Excel2._Workbook oBook  = oBooks.Open(excelFile, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing,
                                                      oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);

                FileInfo fi = new FileInfo(pptFileName);

                //string pptTempName = fi.DirectoryName + @"\TEMP.pptm";

                oPP = new PowerPoint.Application();
                oPP.DisplayAlerts = Microsoft.Office.Interop.PowerPoint.PpAlertLevel.ppAlertsNone;
                //oPP.Visible = MsoTriState.msoFalse;

                oPresSet    = oPP.Presentations;
                _activePres = oPresSet.Open(fi.FullName, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);

                //Object[] oRunArgs = { "'" + fi.Name + "'!M2" };
                Object[] oRunArgs = { "'" + fi.Name + "'!" + macro };
                oPP.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null,
                                           oPP, oRunArgs);

                //close Excel
                try
                {
                    //excelProc.CloseMainWindow();
                    //excelProc.Close();
                    //excelProc.Dispose();
                    //excelProc.Kill();
                }
                catch (Exception exCloseExcel)
                {
                    //excelProc.Kill();
                }

                //save excel file
                //oBook.Save();

                // Quit Excel and clean up.
                Thread.Sleep(1000);
                oBook.Close(false, oMissing, oMissing);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook);
                oBook = null;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks);
                oBooks = null;
                oExcel.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel);
                oExcel = null;


                mess += "kill excel" + Environment.NewLine;

                //_activePres.Final = false;

                Thread.Sleep(2000);

                _activePres.Save();

                //_activePres.SaveAs(pptTempName);

                mess += "save ppt temp" + Environment.NewLine;

                Thread.Sleep(2000);

                //_activePres.Final = true;

                // Quit PPT and clean up.
                if (_activePres != null)
                {
                    mess += "check activepres = null" + Environment.NewLine;
                    try
                    {
                        _activePres.Close();
                        mess += "activepres close" + Environment.NewLine;
                    }
                    catch (Exception exClosePresentation) { }

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(_activePres);
                    mess       += "release activepres" + Environment.NewLine;
                    _activePres = null;
                    mess       += "activepres = null" + Environment.NewLine;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oPresSet);
                    mess    += "release presset" + Environment.NewLine;
                    oPresSet = null;
                    mess    += "presset null" + Environment.NewLine;
                    try
                    {
                        Thread.Sleep(1000);
                        oPP.Quit();
                        mess += "opp quit" + Environment.NewLine;
                    }
                    catch (Exception exQuitPPT) { }

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oPP);
                    mess += "release opp" + Environment.NewLine;
                    oPP   = null;
                    mess += "opp = null" + Environment.NewLine;
                }

                GC.Collect();
                mess += "garbage" + Environment.NewLine;

                //Kill PPT File
                var processes = from p in Process.GetProcessesByName("POWERPNT") select p;

                foreach (var process in processes)
                {
                    //if (process.MainWindowTitle == "TEMP.pptm")
                    try
                    {
                        mess += "test process null" + Environment.NewLine;
                        if (process != null)
                        {
                            process.Close();
                            Thread.Sleep(1000);
                            mess += "close process" + Environment.NewLine;

                            if (process != null)
                            {
                                process.Kill();
                                mess += "kil process" + Environment.NewLine;
                            }
                        }
                    }
                    catch (Exception exCloseProc) { }
                }

                //rename file & delete temp file
                //if (File.Exists(pptFileName))
                //{
                //    File.Delete(pptFileName);
                //    mess += "delete ppt" + Environment.NewLine;
                //    File.Move(pptTempName, pptFileName);
                //    mess += "move temp" + Environment.NewLine;
                //}

                //if (File.Exists(pptTempName))
                //    File.Delete(pptTempName);
                //mess += "delete temp" + Environment.NewLine;
            }
            catch (Exception ex)
            {
                if (_activePres != null)
                {
                    try
                    {
                        _activePres.Close();
                    }
                    catch (Exception ex2) { }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oPresSet);
                    oPresSet = null;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(_activePres);
                    _activePres = null;
                }

                if (oPP != null)
                {
                    try
                    {
                        oPP.Quit();
                    }
                    catch (Exception ex2) { }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oPP);
                    oPP = null;
                }

                log.Error("Error :: RunPPTMacro : " + ex.Message);
                throw ex;
            }
        }
Beispiel #32
0
        //Create a new and initialize it;s presentation
        public void Init()
        {
            objApp = new PowerPoint.Application();

            flag = 0;

            objPresSet = objApp.Presentations;
            //objPres = objPresSet.Add(MsoTriState.msoTrue);

               objPres= objPresSet.Open("c://sample.pptx");
            objSlides = objPres.Slides;
        }
Beispiel #33
0
        /*      delegate void SetTextCallback(string text);
        private void SetText(string text)
        {
            Debug.Print(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name); //---------
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.lblSTrigger.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                this.lblSTrigger.Text = text;
            }
        }                  */
        private void PresentationStart()
        {
            Debug.Print(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name); //---------
            try
            {
                objApp = new PowerPoint.Application();
                objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                objPresSet = objApp.Presentations;
                objPres = objPresSet.Open(stSettings.strPPath, Microsoft.Office.Core.MsoTriState.msoFalse, // MsoTriState ReadOnly,
                Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);    //MsoTriState Untitled,MsoTriState WithWindow
            }
            catch (Exception e)
            {
                this.Activate();
                MessageBox.Show(e.Message);
                tsmPresentationStop_Click(null, null);
                return;
            }

            //objSlides = objPres.Slides;

            //Run the Slide show
            objSSS = objPres.SlideShowSettings;
            objSSS.ShowType = Microsoft.Office.Interop.PowerPoint.PpSlideShowType.ppShowTypeSpeaker;
            objSSS.LoopUntilStopped = Microsoft.Office.Core.MsoTriState.msoTrue;

            if (stSettings.bytRunMacro == 0 || stSettings.strPPMacroName=="")
            {
                objSSS.Run();
            }
            else
            {
                object[] oRunArgs = new Object[] { "'" + objPres.Name + "'!" + stSettings.strPPMacroName, stSettings.strMParam1, stSettings.strMParam2, stSettings.strMParam3 };
                try
                {
                    objApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, objApp, oRunArgs);
                    originalPWidth = objPres.SlideShowWindow.Width;
                }
                catch (System.Runtime.InteropServices.COMException e)
                {
                    MessageBox.Show(e.Message + "\n" + "\n" + e.Source + "\n" + e.StackTrace);
                    return;
                }
                catch (Exception e)
                {
                    this.Activate();
                    MessageBox.Show(e.Message + "\n" + "\n" + e.InnerException.Source + "\nn" + e.InnerException.Message);
                    return;
                }
            }

            //handle
            //IntPtr hwnd = new IntPtr(objPres.SlideShowWindow.HWND);
            //WindowWrapper handleWrapper = new WindowWrapper(hwnd);
            //SetParent(handleWrapper.Handle, this.Handle);
            //this.Visible = true;
            if (stSettings.bytFullScreenPres==0)
            {
                SlideShowSize();
                //WinApi.HideTray();
                Taskbar.Hide();
            }
        }
Beispiel #34
0
 /// <summary>
 /// 打开被选中的幻灯片
 /// </summary>
 /// <param name="strTemplate"></param>
 private void ShowPresentation(string strTemplate)
 {
     objApp = new PowerPoint.Application();
     objApp.Visible = MsoTriState.msoTrue;
     objPresSet = objApp.Presentations;
     objPres = objPresSet.Open(strTemplate,
         MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
     objSlides = objPres.Slides;
 }
Beispiel #35
0
        void openPPt()
        {
            ppt = new PowerPoint.Application();
            ppt.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;

            spPt = ppt.Presentations;
            openPt = spPt.Open(pptname, MsoTriState.msoFalse, MsoTriState.msoFalse);
            openPt.SlideShowSettings.Run();
        }
Beispiel #36
0
        private void InsertItem(IFileItem item)
        {
            if (item == null)
            {
                return;
            }

            PPT.Application   app  = new PPT.Application();
            PPT.Presentations pres = app.Presentations;

            PPT.Presentation pptx   = pres.Open(item.File.FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
            PPT.Slides       slides = pptx.Slides;
            PPT.Slide        slide  = slides[item.Index];

            if (item.Type == ItemType.Slide)
            {
                slide.Copy();
            }
            else
            {
                PPT.Shapes shapes = slide.Shapes;
                PPT.Shape  shape  = shapes[1];

                shape.Copy();

                shapes.ReleaseCOM();
                shapes = null;
                shape.ReleaseCOM();
                shape = null;
            }

            PPT.Presentation dstpptx = app.ActivePresentation;

            PPT.DocumentWindow wnd  = app.ActiveWindow;
            PPT.View           view = wnd.View;

            //TODO: Check if there is no selection (selection between slides)
            PPT.Slides dstSlides = dstpptx.Slides;
            PPT.Slide  dstSlide  = null;

            dstSlide = view.Slide as PPT.Slide;
            int ix = dstSlide.SlideIndex + 1;

            if (item.Type == ItemType.Slide)
            {
                dstSlide.Copy();

                var r = dstSlides.Paste(); //TODO: dstSlides.Paste(ix) Hangs here
                var s = r[1];

                s.MoveTo(ix);

                s.ReleaseCOM();
                s = null;

                r.ReleaseCOM();
                r = null;
            }
            else
            {
                view.Paste();
            }

            dstSlide.ReleaseCOM();
            dstSlide = null;

            wnd.ReleaseCOM();
            wnd = null;

            view.ReleaseCOM();
            view = null;

            dstpptx.ReleaseCOM();
            dstpptx = null;


            slide.ReleaseCOM();
            slide = null;

            slides.ReleaseCOM();
            slides = null;

            pptx.Close();
            pptx.ReleaseCOM();
            pptx = null;

            pres.ReleaseCOM();
            pres = null;

            app.ReleaseCOM();
            app = null;

            dstSlides.ReleaseCOM();
            dstSlides = null;
        }
Beispiel #37
0
        public List <Segment> redPPTXFile(string path, char[] delimiters)
        {
            string         filename = Path.GetFileName(path);
            List <Segment> result   = new List <Segment>();

            try
            {
                Microsoft.Office.Interop.PowerPoint.Application   application         = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Application   pwpApp              = new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = pwpApp.Presentations;
                Microsoft.Office.Interop.PowerPoint.Presentation  presentation        = multi_presentations.Open(path, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
                foreach (Slide slide in presentation.Slides)
                {
                    int indexShape = 1;
                    foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
                    {
                        if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            var textFrame = shape.TextFrame;
                            if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
                            {
                                var           textRange = textFrame.TextRange;
                                string        text      = textRange.Text.ToString();
                                List <string> tmp       = splitTxtContentToSegment(text, delimiters);
                                foreach (string str in tmp)
                                {
                                    tm tm = new tm();
                                    tm.Source = str;
                                    int     indexSlide = slide.SlideIndex;
                                    Segment segment    = new Segment();
                                    segment.slide = indexSlide;
                                    segment.shape = indexShape;
                                    segment.file  = filename;
                                    segment.setTM(tm);
                                    result.Add(segment);
                                }
                            }
                        }
                        indexShape++;
                    }
                }

                presentation.Save();
                presentation.Close();
                pwpApp.Quit();
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Beispiel #38
0
        public List <IFileItem> AppendSlides(List <PPT.Slide> srcSlides)
        {
            PPT.Application   ppt             = null;
            PPT.Presentations pres            = null;
            PPT.Presentation  pptPresentation = null;
            try
            {
                ppt  = new PPT.Application();
                pres = ppt.Presentations;

                pptPresentation = pres.Open(FullPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);

                PPT.DocumentWindow wnd = pptPresentation.Windows[1];
                //wnd.Height = 200;
                //wnd.Top = -200;
                wnd.WindowState = PPT.PpWindowState.ppWindowMinimized;
                wnd             = null;

                #region Alt. slower approach by copy ppt and insert slides from file
                //Copy
                //string tempFile = @"c:\WRK\Temp.pptx";
                //ppt.ActivePresentation.SaveCopyAs(tempFile, PPT.PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoTrue);
                //PPT.Presentation tempPPT = ppt.Presentations.Open(tempFile,MsoTriState.msoFalse,MsoTriState.msoFalse, MsoTriState.msoFalse);

                //List<string> slideNames = slides.Select(slide => slide.Name).ToList();
                //var v = from PPT.Slide sl in tempPPT.Slides where !slideNames.Contains(sl.Name) select sl;
                //foreach(PPT.Slide s in v)
                //{
                //    s.Delete();
                //}
                //tempPPT.Save();
                //tempPPT.Close();
                //gallery.Slides.InsertFromFile(tempFile, gallery.Slides.Count);
                #endregion

                PPT.Slides gSlides    = pptPresentation.Slides;
                int        startIndex = gSlides.Count + 1;
                foreach (PPT.Slide slide in srcSlides)
                {
                    slide.Copy();
                    gSlides.Paste();
                }
                List <IFileItem> newItems = new List <IFileItem>();
                newItems = fileIndex.UpdateIndex(pptPresentation, startIndex);

                return(newItems);
            }
            finally
            {
                if (pptPresentation != null)
                {
                    pptPresentation.Save();
                    pptPresentation.Close();
                }
                pptPresentation.ReleaseCOM();
                pptPresentation = null;

                pres.ReleaseCOM();
                pres = null;

                ppt.ReleaseCOM();
                ppt = null;
            }
        }
        public static void ShowPresentation(string path)
        {
            String strTemplate ; //, strPic;
            string Base = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

            string LocalDir = System.IO.Path.GetDirectoryName(Base).Replace("file:\\", "");

            strTemplate = System.IO.Path.Combine(LocalDir, "Resources", "Template.pptx");
            //"\\\\flrblr001\\windows_data\\From-SLI-Fileserver\\E\\Product Engineering\\Sundar\\svn\\trunk\\CommonBase\\DeviceSpecific\\Si53300\\sample_data\\Template.pptx";
            //strPic = "C:\\Windows\\Blue Lace 16.bmp";
            //bool bAssistantOn;
            if (!System.IO.File.Exists(strTemplate)) {
                System.Windows.MessageBox.Show("Template file is missing, create the file: " + strTemplate);
            }
            //Create a new presentation based on a template.
            objApp = new PowerPoint.Application();
            objApp.Visible = MsoTriState.msoTrue;
            objPresSet = objApp.Presentations;
            objPres = objPresSet.Open(strTemplate,
              MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            objSlides = objPres.Slides;
            objApp.WindowState = Microsoft.Office.Interop.PowerPoint.PpWindowState.ppWindowMinimized;
        }