예제 #1
0
        public static void ReadSlide()
        {
            try
            {
                string filePath = CurrentDirectory() + fileName;

                Application   pptApplication      = new Application();
                Presentations multi_presentations = pptApplication.Presentations;
                Presentation  presentation        = multi_presentations.Open(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);

                string presentationText = string.Empty;
                foreach (var item in presentation.Slides[1].Shapes)
                {
                    var shape = (Microsoft.Office.Interop.PowerPoint.Shape)item;
                    if (shape.HasTextFrame == MsoTriState.msoTrue)
                    {
                        if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                        {
                            var textRange = shape.TextFrame.TextRange;
                            var text      = textRange.Text;

                            presentationText += text + " ";
                        }
                    }
                }

                Console.WriteLine(presentationText);
            }
            catch (Exception ex)
            {
                WriteException(ex.ToString());
            }
        }
예제 #2
0
        void PresenterInterface.StartPresintation()
        {
            Application ppApp = new Application();

            ppApp.Visible = MsoTriState.msoTrue;
            Presentations     ppPresens = ppApp.Presentations;
            Presentation      objPres   = ppPresens.Open(@"E:\\courseWork\\CourseProject\\CourseWork\\CourseWork\\exports\\presentation.pptx", MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            Slides            objSlides = objPres.Slides;
            int               n         = objSlides.Count; //получаю количество слайдов в показываемой презентации
            SlideShowWindows  objSSWs;
            SlideShowSettings objSSS;


            objSSS             = objPres.SlideShowSettings;
            objSSS.EndingSlide = n - 2;
            objSSS.Run();
            objSSWs = ppApp.SlideShowWindows;

            Thread.Sleep(n * 5000);// пауза между слайдами так как 1 секунда переход 2 секунды слайд

            objPres.Close();
            ppApp.Quit();

            //закрываем потоки
            var processes = System.Diagnostics.Process.GetProcessesByName("POWERPNT");

            foreach (var p in processes)
            {
                p.Kill();
            }
        }
예제 #3
0
    public string  ReadSlide()
    {
        string presentationText = string.Empty;

        try
        {
            string filePath = System.Web.HttpContext.Current.Server.MapPath("~/TemplatePPT/Plantilla1.pptx");

            Application   pptApplication      = new Application();
            Presentations multi_presentations = pptApplication.Presentations;
            Presentation  presentation        = multi_presentations.Open(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
            foreach (var item in presentation.Slides[1].Shapes)
            {
                var shape = (Microsoft.Office.Interop.PowerPoint.Shape)item;
                if (shape.HasTextFrame == MsoTriState.msoTrue)
                {
                    if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                    {
                        var textRange = shape.TextFrame.TextRange;
                        var text      = textRange.Text;

                        presentationText += text + " ";
                    }
                }
            }

            Console.WriteLine(presentationText);
        }
        catch (Exception ex)
        {
        }
        return(presentationText);
    }
        /// <summary>
        /// Open PPT App and opens dialog to select presentation
        /// </summary>
        /// <returns></returns>
        public bool OpenPowerPoint()
        {
            try
            {
                //Create an instance of PowerPoint.
                oPPT = new Application();
                // Show PowerPoint to the user.
                oPPT.Visible = MsoTriState.msoTrue;
                objPresSet = oPPT.Presentations;
                OpenFileDialog Opendlg = new OpenFileDialog();

                Opendlg.Filter = "Powerpoint|*.ppt;*.pptx|All files|*.*";

                // Open file when user  click "Open" button
                if (Opendlg.ShowDialog() == true)
                {
                    string pptFilePath = Opendlg.FileName;
                    //open the presentation
                    objPres = objPresSet.Open(pptFilePath, MsoTriState.msoFalse,
                    MsoTriState.msoTrue, MsoTriState.msoTrue);

                    objPres.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
                    objPres.SlideShowSettings.Run();
                    
                    oSlideShowView = objPres.SlideShowWindow.View;
                    return true;
                }
                return false;
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to open Power Point, please make sure you have the program installed correctly");
                return false;
            }
        }
예제 #5
0
 public bool load(string file)
 {
     if (this.powerpoint == null)
     {
         return(false);
     }
     try
     {
         string fileName = file.Trim();
         presentations = powerpoint.Presentations;
         presentation  = presentations.Open(fileName,
                                            Microsoft.Office.Core.MsoTriState.msoFalse,
                                            Microsoft.Office.Core.MsoTriState.msoFalse,
                                            Microsoft.Office.Core.MsoTriState.msoTrue);
         slides = presentation.Slides;
         return(true);
     }
     catch
     {
         presentation = null;
         slides       = null;
         return(false);
     }
     //Thread.Sleep(5000);
 }
예제 #6
0
        static void Main(string[] args)
        {
            if (!CheckInputFilePath(args[0]) || !CheckOutputFilePathDirectory(args[1]))
            {
                Console.WriteLine("Input Error : make sure you are providing correct input in console");
                Console.WriteLine("Help : your first argument is your input Presentation file. It must be a full file path like E:\\TestFile\\SlideQTestCount.pptx");
                Console.WriteLine("Help : your second argument is your output file. It must be a full file path and in this make sure the parent directory Exists on your system, file will be created automatically and only xls extention allowed like f:\\count.xls ");
                return;
            }
            Application ppApp = new Application();

            ppApp.Visible = MsoTriState.msoTrue;
            Presentations            oPresSet           = ppApp.Presentations;
            _Presentation            PPTObject          = oPresSet.Open(@args[0], MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);
            SmellDetector            detector           = new SmellDetector();
            List <PresentationSmell> SlideDataModelList = detector.detectPresentationSmells(PPTObject.Slides);

            PPTObject.Close();
            try
            {
                Excelgenerator(SlideDataModelList, args[1]);
            }
            catch (Exception ex)
            {
                Console.WriteLine("message " + ex.Message);
            }
        }
예제 #7
0
        /// <summary>
        /// Open PPT App and opens dialog to select presentation
        /// </summary>
        /// <returns></returns>
        public bool OpenPowerPoint()
        {
            try
            {
                //Create an instance of PowerPoint.
                oPPT = new Application();
                // Show PowerPoint to the user.
                oPPT.Visible = MsoTriState.msoTrue;
                objPresSet   = oPPT.Presentations;
                OpenFileDialog Opendlg = new OpenFileDialog();

                Opendlg.Filter = "Powerpoint|*.ppt;*.pptx|All files|*.*";

                // Open file when user  click "Open" button
                if (Opendlg.ShowDialog() == true)
                {
                    string pptFilePath = Opendlg.FileName;
                    //open the presentation
                    objPres = objPresSet.Open(pptFilePath, MsoTriState.msoFalse,
                                              MsoTriState.msoTrue, MsoTriState.msoTrue);

                    objPres.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
                    objPres.SlideShowSettings.Run();

                    oSlideShowView = objPres.SlideShowWindow.View;
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to open Power Point, please make sure you have the program installed correctly");
                return(false);
            }
        }
예제 #8
0
        static public void LoadPPT(string pptPath)
        {
            StartApp();

            ppt = ppts.Open(pptPath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);

            //ExportImages(Helper.GetCurrentFolder());
        }
예제 #9
0
 public void LoadFile(string fileName)
 {
     _presentations = _app.Presentations;
     _presentation = _presentations.Open(fileName,
                                         MsoTriState.msoFalse,
                                         MsoTriState.msoFalse,
                                         MsoTriState.msoTrue);
 }
예제 #10
0
        SlideNotes[] Extract(string filename)
        {
            List <SlideNotes> slideNotes    = new List <SlideNotes>();
            Application       app           = new Application();
            Presentations     presentations = app.Presentations;
            Presentation      presentation  = presentations.Open(filename);

            foreach (Slide slide in presentation.Slides)
            {
                if (slide.HasNotesPage != MsoTriState.msoTrue)
                {
                    continue;
                }

                List <string> list       = new List <string>();
                SlideRange    notesPages = slide.NotesPage;
                foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in notesPages.Shapes)
                {
                    if (shape.Type == MsoShapeType.msoPlaceholder)
                    {
                        if (shape.PlaceholderFormat.Type == PpPlaceholderType.ppPlaceholderBody)
                        {
                            if (shape.HasTextFrame == MsoTriState.msoTrue)
                            {
                                if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                                {
                                    var      textRange = shape.TextFrame.TextRange;
                                    string[] lines     = textRange.Text.Split(new[] { "\r\n", "\r", "\n" },
                                                                              StringSplitOptions.None
                                                                              );
                                    foreach (string line in lines)
                                    {
                                        if (line.Length > 0)
                                        {
                                            list.Add(line);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                SlideNotes current = new SlideNotes
                {
                    Name        = slide.Name,
                    Notes       = list.ToArray(),
                    SlideNumber = slide.SlideNumber,
                    Total       = presentation.Slides.Count
                };
                slideNotes.Add(current);
            }
            app.Quit();

            return(slideNotes.ToArray());
        }
        public ResponseModel ConvertPptToPdf(string fileLocation, string outLocation)
        {
            Microsoft.Office.Interop.PowerPoint.Application app = null;
            Presentations presentations = null;
            Presentation  presentation  = null;

            try
            {
                if (!File.Exists(outLocation))
                {
                    app = new Microsoft.Office.Interop.PowerPoint.Application
                    {
                        Visible = MsoTriState.msoTrue
                    };
                    presentations = app.Presentations;
                    presentation  = presentations.Open(fileLocation, ReadOnly: MsoTriState.msoCTrue);
                    presentation.ExportAsFixedFormat(outLocation, PpFixedFormatType.ppFixedFormatTypePDF);

                    Marshal.ReleaseComObject(presentations);
                    presentation.Close();
                    Marshal.ReleaseComObject(presentation);
                    app.Quit();
                    Marshal.ReleaseComObject(app);
                }
                else
                {
                    return(new ResponseModel {
                        IsSucceed = false, ErrorMessage = outLocation + " file-ı artıq mövcuddur."
                    });
                }

                if (!File.Exists(outLocation))
                {
                    return(new ResponseModel {
                        IsSucceed = false, ErrorMessage = outLocation + " file-ı tapılmadı."
                    });
                }

                return(new ResponseModel {
                    Data = outLocation, IsSucceed = true, ErrorMessage = string.Empty
                });
            }
            catch (Exception e)
            {
                Marshal.ReleaseComObject(presentations);
                presentation.Close();
                Marshal.ReleaseComObject(presentation);
                app.Quit();
                Marshal.ReleaseComObject(app);
                return(new ResponseModel {
                    IsSucceed = false, ErrorMessage = "File convert oluna bilmədi: " + e.Message
                });
            }
        }
예제 #12
0
 private PowerPoint(string fileName)
 {
     string appProgID = "PowerPoint.Application";
     Type pptType = Type.GetTypeFromProgID(appProgID);
     _application = (Application)Activator.CreateInstance(pptType, true);
     //_application.Visible = MsoTriState.msoTrue;
     _presentations = _application.Presentations;
     _presentation = _presentations.Open(fileName,
                                         MsoTriState.msoTrue,
                                         MsoTriState.msoTrue,
                                         MsoTriState.msoFalse);
 }
예제 #13
0
        public void GetPPTObject()
        {
            string      solution_dir = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.CurrentContext.WorkDirectory));
            string      path         = @solution_dir + @"\TestFile\DECAF.pptx";
            string      absolute     = Path.GetFullPath(path);
            Application ppApp        = new Application();

            ppApp.Visible = MsoTriState.msoTrue;
            Presentations oPresSet = ppApp.Presentations;

            pptObject = oPresSet.Open(@path, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);
        }
예제 #14
0
        public void GetPPTObject()
        {
            string      solution_dir = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.CurrentContext.WorkDirectory));
            string      path         = @solution_dir + @"\TestFile\Table.pptx";
            string      absolute     = Path.GetFullPath(path);
            Application ppApp        = new Application();

            ppApp.Visible = MsoTriState.msoTrue;
            Presentations oPresSet = ppApp.Presentations;

            PPTObject = oPresSet.Open(@path, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue);
            SmellDetector detector = new SmellDetector();

            SlideDataModelList = detector.detectPresentationSmells(PPTObject.Slides);
        }
예제 #15
0
        static public void OpenPPTXPresentation(string pptxPath)
        {
            PowerPoint.Application pptxApplicatoin = new PowerPoint.Application();
            pptxApplicatoin.Visible = MsoTriState.msoTrue;
            Presentations pptxPresentations = pptxApplicatoin.Presentations;
            Presentation  presentation      = pptxPresentations.Open(pptxPath,
                                                                     MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            Slides            objSlides = presentation.Slides;
            SlideShowWindows  SSWindows;
            SlideShowSettings objSSS;

            objSSS = presentation.SlideShowSettings;
            objSSS.Run();
            SSWindows = pptxApplicatoin.SlideShowWindows;
            pptxApplicatoin.Quit();
        }
예제 #16
0
        private static bool WriteOnSlide()
        {
            var    resultado = false;
            string filePath  = CurrentDirectory() + fileName;

            try
            {
                Application   pptApplication      = new Application();
                Presentations multi_presentations = pptApplication.Presentations;
                Presentation  presentation        = multi_presentations.Open(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
                CustomLayout  customLayout        = presentation.SlideMaster.CustomLayouts[PpSlideLayout.ppLayoutText];

                Slides slides = presentation.Slides;
                Microsoft.Office.Interop.PowerPoint.Shapes shapes = presentation.Slides[1].Shapes;
                TextRange objText;

                slides = presentation.Slides;

                var text1 = "Esto es una prueba de escribir en el titulo";
                var text2 = "Estoy escribiendo en la seccion de contenido de la diapositiva PPT";

                objText           = shapes[1].TextFrame.TextRange;
                objText.Text      = text1;
                objText.Font.Name = "Arial";
                objText.Font.Size = 32;

                objText           = shapes[2].TextFrame.TextRange;
                objText.Text      = text2;
                objText.Font.Name = "Arial";
                objText.Font.Size = 28;

                ReadWriteTxt(filePath);
                presentation.SaveAs(filePath, PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
                presentation.Close();
                pptApplication.Quit();

                resultado = true;
            }
            catch (Exception ex)
            {
                WriteException(ex.ToString());
            }
            return(resultado);
        }
예제 #17
0
        public static bool ConvertPowerPointToPdf(string inputFile, string outputfile)
        {
            string outputFileName = outputfile;

            Microsoft.Office.Interop.PowerPoint.Application powerPointApp =
                new Microsoft.Office.Interop.PowerPoint.Application();
            Presentation  presentation  = null;
            Presentations presentations = null;

            try
            {
                presentations = powerPointApp.Presentations;
                presentation  = presentations.Open(inputFile, MsoTriState.msoFalse, MsoTriState.msoFalse,
                                                   MsoTriState.msoFalse);

                presentation.ExportAsFixedFormat(outputFileName, PpFixedFormatType.ppFixedFormatTypePDF,
                                                 PpFixedFormatIntent.ppFixedFormatIntentScreen, MsoTriState.msoFalse,
                                                 PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, PpPrintOutputType.ppPrintOutputSlides,
                                                 MsoTriState.msoFalse, null, PpPrintRangeType.ppPrintAll, string.Empty, false, true, true, true, false,
                                                 Type.Missing);
            }
            catch (Exception)
            {
                MessageBox.Show("Co loi xay ra");
                return(false);
            }
            finally
            {
                if (presentation != null)
                {
                    presentation.Close();
                    Marshal.ReleaseComObject(presentation);
                    presentation = null;
                }
                if (powerPointApp != null)
                {
                    powerPointApp.Quit();
                    Marshal.ReleaseComObject(powerPointApp);
                    powerPointApp = null;
                }
            }
            return(true);
        }
예제 #18
0
    public bool WriteOnSlide()
    {
        var    resultado = false;
        string filePath  = System.Web.HttpContext.Current.Server.MapPath("~/TemplatePPT/Plantilla1.pptx");

        try
        {
            Application   pptApplication      = new Application();
            Presentations multi_presentations = pptApplication.Presentations;
            Presentation  presentation        = multi_presentations.Open(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
            CustomLayout  customLayout        = presentation.SlideMaster.CustomLayouts[PpSlideLayout.ppLayoutText];

            Slides slides = presentation.Slides;
            Microsoft.Office.Interop.PowerPoint.Shapes shapes = presentation.Slides[1].Shapes;
            TextRange objText;

            slides = presentation.Slides;

            var text1 = "Escribiendo en el titulo: " + DateTime.Now.ToString();
            var text2 = "Descripcion PPT: " + DateTime.Now.ToString();

            objText           = shapes[1].TextFrame.TextRange;
            objText.Text      = text1;
            objText.Font.Name = "Arial";
            objText.Font.Size = 32;

            objText           = shapes[2].TextFrame.TextRange;
            objText.Text      = text2;
            objText.Font.Name = "Arial";
            objText.Font.Size = 28;

            ReadWriteTxt(filePath);
            presentation.SaveAs(filePath, PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoTrue);
            presentation.Close();
            pptApplication.Quit();
            resultado = true;
        }
        catch (Exception ex)
        {
        }
        return(resultado);
    }
예제 #19
0
 public bool load(string file)
 {
     if (this.powerpoint == null) return false;
       try
       {
     string fileName = file.Trim();
     presentations = powerpoint.Presentations;
     presentation = presentations.Open(fileName,
                                   Microsoft.Office.Core.MsoTriState.msoFalse,
                                   Microsoft.Office.Core.MsoTriState.msoFalse,
                                   Microsoft.Office.Core.MsoTriState.msoTrue);
     slides = presentation.Slides;
     return true;
       }
       catch
       {
     presentation = null;
     slides = null;
     return false;
       }
       //Thread.Sleep(5000);
 }
예제 #20
0
        private static void ConvertPowerPointToPdf(string filePath)
        {
            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
            string outputFilePath           = OutputFolder + fileNameWithoutExtension + ".pdf";

            Microsoft.Office.Interop.PowerPoint.ApplicationClass applicationClass = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
            Presentation presentation = null;

            try
            {
                Presentations presentations = applicationClass.Presentations;
                presentation = presentations.Open(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
                presentation.ExportAsFixedFormat(outputFilePath, PpFixedFormatType.ppFixedFormatTypePDF,
                                                 PpFixedFormatIntent.ppFixedFormatIntentScreen, MsoTriState.msoFalse,
                                                 PpPrintHandoutOrder.ppPrintHandoutVerticalFirst, PpPrintOutputType.ppPrintOutputSlides,
                                                 MsoTriState.msoFalse, null, PpPrintRangeType.ppPrintAll, string.Empty, false, true, true, true, false, Type.Missing);
            }
            catch (System.Exception e)
            {
                log.Error("Eccezione durante la conversione del file PowerPoint " + filePath);
                log.Error(e.StackTrace);
                File.Move(filePath, ErrorFolder + Path.GetFileName(filePath));
            }
            finally
            {
                if (presentation != null)
                {
                    presentation.Close();
                    Marshal.ReleaseComObject(presentation);
                }
                if (applicationClass != null)
                {
                    applicationClass.Quit();
                    Marshal.ReleaseComObject(applicationClass);
                }
                CloseProcess("powerpnt");
                File.Delete(filePath);
            }
        }
예제 #21
0
        /// <summary>
        /// Prints a document using interop services.
        /// </summary>
        /// <param name="file">The file to print.</param>
        /// <param name="printQueue">The <see cref="PrintQueue" /> to print the file to.</param>
        /// <param name="printOptions">The <see cref="FilePrintOptions" /> to use for printing the file.</param>
        /// <returns>A <see cref="FilePrintResult" /> object representing the outcome of the print operation.</returns>
        protected override FilePrintResult PrintInterop(FileInfo file, PrintQueue printQueue, FilePrintOptions printOptions)
        {
            ProcessUtil.KillProcess("POWERPNT");

            Application   powerpoint    = null;
            Presentations presentations = null;
            Presentation  presentation  = null;

            try
            {
                OnStatusChanged("Starting PowerPoint");
                powerpoint = new Application();
                powerpoint.DisplayAlerts = PpAlertLevel.ppAlertsNone;

                OnStatusChanged("Opening file: " + file.Name);
                presentations = powerpoint.Presentations;
                presentation  = presentations.Open(file.FullName,
                                                   ReadOnly: MsoTriState.msoCTrue,
                                                   WithWindow: MsoTriState.msoFalse);

                // Check for the word "on" in the queue name.  If it exists, include the port in the name.
                string queueName = printQueue.FullName;
                if (queueName.Contains(" on ") || queueName.StartsWith("on ", false, CultureInfo.CurrentCulture) || queueName.EndsWith(" on", false, CultureInfo.CurrentCulture))
                {
                    queueName = GetQueueNameWithPort(printQueue);
                }

                try
                {
                    OnStatusChanged($"Setting active printer to {queueName}");
                    presentation.PrintOptions.ActivePrinter = queueName;
                }
                catch
                {
                    throw new FilePrintException($"PowerPoint cannot print to '{queueName}'.  Check the formatting of the queue name.");
                }

                OnStatusChanged("Printing to: " + queueName);
                DateTimeOffset startTime = DateTimeOffset.Now;
                presentation.PrintOptions.PrintInBackground = MsoTriState.msoFalse;
                presentation.PrintOut(Copies: printOptions.Copies, Collate: MsoTriState.msoFalse);
                DateTimeOffset endtime = DateTimeOffset.Now;

                OnStatusChanged("Closing presentation...");
                presentation.Close();

                OnStatusChanged("Quitting PowerPoint.");
                powerpoint.Quit();

                return(new FilePrintResult(startTime, endtime));
            }
            finally
            {
                if (presentation != null)
                {
                    Marshal.FinalReleaseComObject(presentation);
                    presentation = null;
                }

                if (presentations != null)
                {
                    Marshal.FinalReleaseComObject(presentations);
                    presentations = null;
                }

                if (powerpoint != null)
                {
                    Marshal.FinalReleaseComObject(powerpoint);
                    powerpoint = null;
                }

                GarbageCollect();
            }
        }
예제 #22
0
        public static void TestPresentation()
        {
            Application   PowerPoint_App      = new Application();
            Presentations multi_presentations = PowerPoint_App.Presentations;
            Presentation  presentation        = multi_presentations.Open(FilesController.openFile());
            string        presentation_text   = "";

            for (int i = 0; i < presentation.Slides.Count; i++)
            {
                foreach (var item in presentation.Slides[i + 1].Shapes)
                {
                    var shape = (Microsoft.Office.Interop.PowerPoint.Shape)item;
                    if (shape.HasTextFrame == MsoTriState.msoTrue)
                    {
                        if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                        {
                            var textRange = shape.TextFrame.TextRange;
                            //Console.WriteLine("sentence: " + textRange.Sentences().Length);

                            //check if there are more than two lines, and needs additional divisions
                            if (textRange.Lines().Count > 2)
                            {
                                int   slideNumber   = shape.Parent.SlideIndex;
                                float slideDuration = presentation.Slides[i + 1].SlideShowTransition.AdvanceTime;
                                presentation.Slides[i + 1].Delete();
                                //CustomLayout customLayout = presentation.SlideMaster.CustomLayouts[PpSlideLayout.ppLayoutText];
                                if (textRange.Sentences().Count > 1)
                                {
                                    //the number represents to how many slides to divide
                                    int   divisionNumber = textRange.Sentences().Count;
                                    float duration       = TwoLines.durationAfterDivisions(slideDuration, divisionNumber);

                                    foreach (TextRange sentence in textRange.Sentences())
                                    {
                                        SlidesManipulation.createNewSlide(presentation.Slides, slideNumber++, sentence.Text.Trim(), duration);
                                    }
                                }
                                else
                                {
                                    int    divisionNumber = textRange.Lines().Count;
                                    float  duration       = TwoLines.durationAfterDivisions(slideDuration, divisionNumber / 2);
                                    string textFrmLines   = "";
                                    foreach (TextRange line in textRange.Lines())
                                    {
                                        if (textFrmLines.Length > 0)
                                        {
                                            textFrmLines += line.Text;
                                            SlidesManipulation.createNewSlide(presentation.Slides, slideNumber++, textFrmLines, duration);
                                            textFrmLines = "";
                                        }
                                        else
                                        {
                                            textFrmLines += line.Text;
                                        }
                                    }
                                }
                            }
                            var text = textRange.Text;
                            presentation_text += text + " ";
                        }
                    }
                }
            }
            PowerPoint_App.Quit();
            Console.WriteLine(presentation_text);
            FilesController.saveSlides(presentation);
        }