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();
        }
Example #2
0
 public static String CreateObj()
 {
     String eString = "";
     if (objpre != null)
     {
         eString = "PC端已打开了PPT文件。若要打开其它PPT,请先关闭当前文件,并点击一次next或prev按钮";
         Debug.WriteLine(eString);
         return eString;
     }
     try
     {
         objpre = objapp.Presentations.Open(filepath, OFFICECORE.MsoTriState.msoTrue, OFFICECORE.MsoTriState.msoTrue, OFFICECORE.MsoTriState.msoTrue);
         objset = objpre.SlideShowSettings;
         objset.Run();
         eString = "调用PPT文件成功 :";
         intNowPage = 0;
         intPer = 0;
         intPageSize = objpre.Slides.Count;
         Debug.WriteLine(eString);
     }
     catch (Exception)
     {
         intNowPage = 0;
         intPer = 0;
         intPageSize = 1;
         eString = "打开PPT文件失败,异常原因是没有选择文件或选择的文件不是PPT " ;
     }
     return eString;
 }
Example #3
0
        public int loadFile(String filename)
        {
            //Create app and open file
            app = new PPT.Application();
            pres = app.Presentations.Open(filename, Core.MsoTriState.msoFalse,
                Core.MsoTriState.msoFalse, Core.MsoTriState.msoFalse);

            if (pres == null)
            {
                sss = null;
                ssw = null;
                ssv = null;

                loaded = false;
                visible = false;
                return -1;
            }

            app.Visible = Core.MsoTriState.msoFalse;

            sss = pres.SlideShowSettings;
            sss.ShowType = PPT.PpSlideShowType.ppShowTypeKiosk;
            ssw = sss.Run();
            ssv = ssw.View;

            loaded = true;
            visible = true;
            return pres.Slides.Count;
        }
 public void Initialised(object context)
 {
     presentation = (PowerPoint.Presentation) context;
     if (presentation == null) return;
     application = presentation.Application;
     application.PresentationNewSlide += ApplicationOnPresentationNewSlide;
 }
        private void cmdCreateDictionary_Click(object sender, EventArgs e)
        {
            dictionaryName = txtDictionary.Text;

            if (!api.dictionary_exists(dictionaryName))
            {
                if (dictionaryName != "")
                {
                   // PowerPoint.Presentation pres = Globals.ThisAddIn.Application.ActivePresentation;
                    pres = Globals.ThisAddIn.Application.ActivePresentation;
                    string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    location = filePath + "\\Dictionaries\\" + dictionaryName;

                    pres.SaveAs(location, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoTrue);
                    pres.Save();

                    api.addDictionary(dictionaryName, location + ".pptx");

                    MessageBox.Show("Dictionary added");
                    pnlAssociations.Enabled = true;
                    pnlDictionary.Enabled = false;

                }
            }
            else
            {
                MessageBox.Show("Already exists");
            }
        }
 public clsMediaListItem(MediaTypeEnum m, string filename, int MediaID, List<clsSlidePictureItem> slideImages, MOIP.Presentation xPres)
 {
     this.ID = MediaID;
     this.mediaType = m;
     this.filename = filename;
     this.SlideImages = slideImages;
     this.PPTPresentation = xPres;
 }
 public SlideshowManager(string presentationFile)
 {
     this.PresentationFile = presentationFile;
     this.PowerPointApp = new PowerPoint.Application();
     this.PowerPointApp.Activate();
     Presentation = this.PowerPointApp.Presentations.Open(presentationFile);
     Presentation.SlideShowSettings.Run();
 }
Example #8
0
 //
 //**********************************************************************************************
 //
 // Class TPPT
 //   Part of  : TDRFree
 //   Function : Interacts with Microsoft Powerpoint to make a presentation
 //   Author   : Jan G. Wesseling
 //   Date     : April 9th, 2013
 //
 //**********************************************************************************************
 //
 public TPPT()
 {
     MyApp = new PowerPoint.Application();
       MyApp.Visible = MsoTriState.msoTrue;
       MyApp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized;
     MyPresentations = MyApp.Presentations;
       MyPresentation = MyPresentations.Add(MsoTriState.msoFalse);
       MySlides = MyPresentation.Slides;
 }
 public void Setup()
 {
     CultureUtil.SetDefaultCulture(CultureInfo.GetCultureInfo("en-US"));
     App = new PowerPoint.Application();
     Pres = App.Presentations.Open(
         PathUtil.GetDocTestPath() + GetTestingSlideName(),
         WithWindow: MsoTriState.msoFalse);
     PpOperations = new UnitTestPpOperations(Pres, App);
 }
Example #10
0
 public void KillApplications()
 {
     //Kill All the processes
     var pptProcesses = Process.GetProcessesByName("powerpnt");
     foreach (var p in pptProcesses)
         p.Kill();
     g_ApplicationStarted = false;
     g_PPT_Application = null;
     g_PPT_PresentationToBeProjected = null;
 }
Example #11
0
        public static async void ApplyTemplate(Object data)
        {
            ResourceData resourceData = data as ResourceData;

            if (resourceData != null)
            {
                string  strUrl  = resourceData.FileUrl;
                string  strPath = Request.HttpDownload(strUrl).Result;
                JObject jObject = new JObject();
                jObject.Add("sjh", Rigel.UserID);
                jObject.Add("lb", App.ResourceType.ToString());
                jObject.Add("tmid", resourceData.ID);
                String strAPI = "{0}/ppttools/lsjl/save?token={1}";
                String url    = String.Format(strAPI, Rigel.ServerUrl, Rigel.UserToken);
                Request.HttpPost(jObject, url);
                PowerPoint.Presentation currentPPT = Globals.ThisAddIn.Application.ActivePresentation;

                if (App.ResourceType == ResourceType.Template || App.ResourceType == ResourceType.Upload_template)
                {
                    Globals.ThisAddIn.Application.Presentations.Open(strPath);
                }
                else
                {
                    if (currentPPT.Slides.Count > 0)
                    {
                        PowerPoint.Slide currentIndexPPT = (PowerPoint.Slide)Globals.ThisAddIn.Application.ActiveWindow.View.Slide;
                        currentPPT.Slides.InsertFromFile(strPath, currentIndexPPT.SlideIndex, 1, -1);
                        currentPPT. = currentIndexPPT.SlideIndex + 1;
                    }
                    else
                    {
                        currentPPT.Slides.InsertFromFile(strPath, 0, 1, -1);
                    }
                }


                if (App.ResourceType == ResourceType.Predict)
                {
                    string id = resourceData.ID;

                    WriteSlide writer = new WriteSlide();
                    if (id.Equals("100"))
                    {
                        await writer.WriteDataFor100("164");
                    }
                    else if (id.Equals("164"))
                    {
                        await writer.WriteDataFor164();
                    }
                }
            }
        }
        private static void extractPPTXData(string pptxPath)
        {
            List <string> slideNotes      = new List <string>();
            List <string> slideTitles     = new List <string>();
            List <string> slideTexts      = new List <string>();
            List <object> slideNarrations = new List <object>();

            PowerPoint.Application  powerpointapplication = new PowerPoint.Application();
            PowerPoint.Presentation powerpointpresentation
                = powerpointapplication.Presentations.Open(pptxPath,
                                                           WithWindow: Microsoft.Office.Core.MsoTriState.msoFalse);
            int slideCount = powerpointpresentation.Slides.Count;

            foreach (PowerPoint.Slide sld in powerpointpresentation.Slides)
            {
                //Console.WriteLine(sld.Name);

                #region get slide notes
                if (sld.HasNotesPage == Microsoft.Office.Core.MsoTriState.msoTrue)
                {
                    slideNotes.Add(sld.NotesPage.Shapes[2].TextFrame.TextRange.Text);
                }
                #endregion

                #region get slide Title and Text
                string slideText  = "";
                string slideTitle = "";
                foreach (PowerPoint.Shape shp in sld.Shapes)
                {
                    if (shp.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
                    {
                        if (slideTitle.Equals(string.Empty))
                        {
                            slideTitle = shp.TextFrame.TextRange.Text;
                        }
                        else
                        {
                            slideText += shp.TextFrame.TextRange.Text;
                        }
                    }
                }
                slideTitles.Add(slideTitle);
                slideTexts.Add(slideText);
                #endregion
            }


            powerpointpresentation.Close();
            powerpointapplication.Quit();

            //Console.WriteLine(slideCount);
        }
        private bool AbrirEjercicioPowerPoint(int numeroDePregunta)
        {
            if (numeroDePregunta == 2 || numeroDePregunta == 18 ||
                numeroDePregunta == 20 || numeroDePregunta == 30)
            {
                string fileName = "";

                switch (numeroDePregunta)
                {
                    case 2:
                        fileName = "El ajedrez.pptx";
                        break;
                    case 18:
                        fileName = "Tabla.xlsx";
                        break;
                    case 20:
                        fileName = "Foto.docx";
                        break;
                    case 30:
                        fileName = "Extras.docx";
                        break;

                }

                CopiarDatosParaPregunta(fileName, numeroDePregunta, "Power Point");
            }

            int WidthScreen = screenPowerPoint.Bounds.Width;
            int HeightScreen = screenPowerPoint.Bounds.Height;
            int newHeightScreen = HeightScreen - HeightScreen * 200 / 1080;
            ObjPowerPoint = new PowerPoint.Application();

            CopiarPregunta(numeroDePregunta, "Power Point", "pptx");

            string ruta = @"C:\OfficeTrainnerResources\Temp\Pregunta " + numeroDePregunta + @" Ejercicio.pptx";

            if (System.IO.File.Exists(ruta))
            {
                ppt = ObjPowerPoint.Presentations.Open(ruta);

                ObjPowerPoint.ActiveWindow.WindowState = PowerPoint.PpWindowState.ppWindowNormal;
                ObjPowerPoint.ActiveWindow.Height = 811 * newHeightScreen / 1080;
                ObjPowerPoint.ActiveWindow.Width = WidthScreen;
                ObjPowerPoint.ActiveWindow.Left = 0;
                ObjPowerPoint.ActiveWindow.Top = 0;
            }
            else
            {
                return false;
            }
            return true;
        }
Example #14
0
 internal static void RemoveAnimations(PowerPoint.Presentation presentation)
 {
     foreach (PowerPoint.Slide slide in presentation.Slides)
     {
         // Remove transitions
         slide.SlideShowTransition.EntryEffect = PowerPoint.PpEntryEffect.ppEffectNone;
         // Remove effects of individual shapes
         foreach (PowerPoint.Shape shape in slide.Shapes)
         {
             shape.AnimationSettings.Animate = Office.MsoTriState.msoFalse;
         }
     }
 }
Example #15
0
        public void KillApplications()
        {
            //Kill All the processes
            var pptProcesses = Process.GetProcessesByName("powerpnt");

            foreach (var p in pptProcesses)
            {
                p.Kill();
            }
            g_ApplicationStarted            = false;
            g_PPT_Application               = null;
            g_PPT_PresentationToBeProjected = null;
        }
Example #16
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);
        }
Example #17
0
        /// <summary>
        /// 終了時イベント
        /// </summary>
        private void Application_PresentationBeforeClose(PowerPoint.Presentation Pres, ref bool Cancel)
        {
            string PresPath = "";

            if (string.IsNullOrEmpty(Pres.Path) == false)
            {
                // 自分自身のパス
                PresPath = Path.Combine(Pres.Path, Pres.Name);
            }

            if (lstPresPath.Contains(PresPath) == true)
            {
                if (IsEnableStorage(PresPath, Pres) == false)
                {
                    // 自分自身が正しい位置に保存されていない場合
                    Cancel = true;

                    MessageBox.Show(AddInsLibrary.Properties.Resources.msg_warning_save_not_secure, AddInsLibrary.Properties.Resources.msgError, MessageBoxButtons.OK, MessageBoxIcon.Hand);

                    ExecuteSaveAs();

                    return;
                }
                else
                {
                    // S秘A秘以外
                    lstPresPath.Remove(PresPath);
                }
            }

            // 保存されていない場合
            if (Pres.Saved == Microsoft.Office.Core.MsoTriState.msoFalse)
            {
                if (IsEnableStorage(PresPath, Pres) == false)
                {
                    Cancel = true;

                    MessageBox.Show(AddInsLibrary.Properties.Resources.msg_warning_save_not_secure, AddInsLibrary.Properties.Resources.msgError, MessageBoxButtons.OK, MessageBoxIcon.Hand);

                    ExecuteSaveAs();

                    return;
                }
            }

            // 削除処理
            if (ClearListPath() == false)
            {
                Cancel = true;
            }
        }
Example #18
0
        public FileInfo SaveAsHtmlAll(FileInfo htmlFile)
        {
            FileInfo docX = new FileInfo(presentation.FullName);

            htmlFile.Directory.Create();
            if (htmlFile.Exists)
            {
                htmlFile.Delete();
            }
            presentation.SaveAs(htmlFile.FullName, PowerPoint.PpSaveAsFileType.ppSaveAsHTMLDual, Office.MsoTriState.msoFalse);
            presentation.Close();
            presentation = (PowerPoint.Presentation)application.Presentations.Open(docX.FullName, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue);
            return(htmlFile);
        }
Example #19
0
 private void Application_WindowSelectionChange(PowerPoint.Selection Sel)
 {
     PowerPoint.Application  ppApp     = Globals.ThisAddIn.Application;
     PowerPoint.Presentation ActivePPT = Globals.ThisAddIn.Application.ActivePresentation;
     if (ppApp.ActiveWindow.Selection.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
     {
         foreach (PowerPoint.Shape shp in Sel.ShapeRange)
         {
             PPTAttribute.shpList.Add(shp);
         }
     }
     rib.buttonInvalidate();
     //throw new NotImplementedException();
 }
Example #20
0
        public void SaveOffice2003(FileInfo file)
        {
            FileInfo      docX = new FileInfo(presentation.FullName);
            DirectoryInfo dir  = file.Directory;

            dir.Create();
            if (file.Exists)
            {
                file.Delete();
            }
            presentation.SaveAs(file.FullName, PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, Office.MsoTriState.msoFalse);
            presentation.Close();
            presentation = (PowerPoint.Presentation)application.Presentations.Open(docX.FullName, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue);
        }
Example #21
0
        private static void AddDocumentContent(PowerPoint.Presentation presentation, string content)
        {
            using (var comHelper = new COMObjectsHelper())
            {
                var slides = comHelper.Register(() => presentation.Slides);
                PrepareDocument(presentation, slides, comHelper);

                var targetShape = FindEmptyShape(slides, comHelper) ?? CreateNewSlideWithEmptyShape(presentation, comHelper);

                var targetFrame = comHelper.Register(() => targetShape.TextFrame);
                var textRange   = comHelper.Register(() => targetFrame.TextRange);
                textRange.Text = content;
            }
        }
Example #22
0
 public void startPlay()
 {
     if (isPlaying)
     {
         return;
     }
     else
     {
         PowerPoint.Presentation presentation = Globals.ThisAddIn.Application.ActivePresentation;
         presentation.SlideShowSettings.Run();
         show      = presentation.SlideShowWindow;
         isPlaying = true;
     }
 }
Example #23
0
        /// <summary>
        /// Save a PowerPoint presentation
        /// </summary>
        /// <param name="presentationToSave">Handle to PPT.Presentation object to save</param>
        /// <param name="pathAndFileName">Path (including filename) of where to save the presentation</param>
        /// <param name="fileType">PPT.PpSaveAsFileType object</param>
        /// <param name="embedTrueTypeFonts">Whether to embed TrueType fonts</param>
        public void SavePresentationAs(
            PPT.Presentation presentationToSave,
            string pathAndFileName,
            PPT.PpSaveAsFileType fileType,
            bool embedTrueTypeFonts)
        {
            if (embedTrueTypeFonts)
            {
                presentationToSave.SaveAs(pathAndFileName, fileType, OFFICE.MsoTriState.msoTrue);
                return;
            }

            presentationToSave.SaveAs(pathAndFileName, fileType, OFFICE.MsoTriState.msoFalse);
        }
        /// <summary>
        /// Call VBA script from a Powerpoint application.
        /// </summary>
        /// <param name="processName">Name of the process being executed</param>
        /// <param name="officeAppName">One of the office app names</param>
        /// <param name="filePath">File path with the VBA script to be executed</param>
        /// <param name="combinedMacroNameAndArgs"> Array of object with VBA script name with module/procedure name and args</param>
        /// <param name="showAlerts">Boolean status to show alerts on open application</param>
        /// <param name="visibleApp">Boolean status to show open application</param>
        /// <param name="saveFile">Boolean status to save or not the file</param>
        /// <param name="stw">Stream writer object to output message to stream buffer</param>
        /// <returns>Returned string from VBA Main Function</returns>
        private static string _RunVBAonPowerpoint(string processName, string officeAppName, string filePath, object[] combinedMacroNameAndArgs, bool showAlerts = false, bool visibleApp = false, bool saveFile = false, StreamWriter stw = null)
        {
            Powerpoint.Application _pwpApp = new Powerpoint.Application
            {
                DisplayAlerts = showAlerts ? Powerpoint.PpAlertLevel.ppAlertsAll : Powerpoint.PpAlertLevel.ppAlertsNone,
                Visible       = visibleApp ? MsoTriState.msoCTrue : MsoTriState.msoFalse
            };

            if (_pwpApp == null)
            {
                throw new ApplicationException("Powerpoint could not be started. Check if Office Powerpoint is properly installed in your machine/server. If the error persists, contact XPress robot developers and show a printscreen of this log.");
            }
            else
            {
                string message = DateTime.Now + " [INFO] " + officeAppName + " opened successfully!";
                if (stw != null)
                {
                    stw.WriteLine(message + "\n\r");
                }
                Console.WriteLine(message);

                message = DateTime.Now + " [INFO] " + processName + " is running at " + officeAppName + "...";
                if (stw != null)
                {
                    stw.WriteLine(message + "\n\r");
                }
                Console.WriteLine(message);

                // Start Powerpoint and Document
                Powerpoint.Presentation _pwpPres = _pwpApp.Presentations.Open(filePath);

                // Run the macros by supplying the necessary arguments
                // Docs: https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.word._application.run?view=word-pia
                object _result = _RunGenericVBAMacro(_pwpPres, combinedMacroNameAndArgs);

                // Clean-up: Close the document
                _pwpPres.Close();
                ObjectService.ReleaseObject(_pwpPres);

                // Clean-up: Close the word application
                _pwpApp.Quit();
                ObjectService.ReleaseObject(_pwpApp);

                if (_result == null)
                {
                    _result = "ERROR | Something wrong in the " + officeAppName + " script happened. Contact XPress robot developers and show a printscreen of this log.";
                }
                return(_result.ToString());
            }
        }
 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);
     }
 }
Example #26
0
 private void RebuildCache(PowerPoint.Presentation presentation)
 {
     this.myRestrictedShapesTable[presentation.FullName] = new Hashtable();
     foreach (PowerPoint.Slide slide in presentation.Slides)
     {
         foreach (PowerPoint.Shape shape in slide.Shapes)
         {
             if (this.IsRestricted(shape))
             {
                 this.RecacheShapeRestricted(shape);
             }
         }
     }
 }
Example #27
0
        private void HandleWindowActivate(PowerPoint.Presentation presentation, PowerPoint.DocumentWindow window)
        {
            // TODO: need to make a method for building the presentation at this point
            // in case when it was opened/newed it didn't have an active window but
            // now it does. Suggestion: add a tag to the presentation that contains a
            // GUID unique to this instance which will tell us whether THIS INSTANCE
            // has ever built the presentation before? That's actually no good b/c
            // it could have been closed, changed elsewhere, and reopened all while
            // this instance is running. :(

            // Update the mode bars.
            this.ConfigurePresentationModeBar();
            this.ConfigureShapeModeBar();
        }
        private static void AutomatePowerPointImpl()
        {
            try
            {
                // Create an instance of Microsoft PowerPoint and make it
                // invisible.

                PowerPoint.Application oPowerPoint = new PowerPoint.Application();

                // By default PowerPoint is invisible, till you make it visible:
                //oPowerPoint.Visible = Office.MsoTriState.msoFalse;

                // Create a new Presentation.

                PowerPoint.Presentation oPre = oPowerPoint.Presentations.Add(
                    Microsoft.Office.Core.MsoTriState.msoTrue);
                Console.WriteLine("A new presentation is created");

                // Insert a new Slide and add some text to it.

                Console.WriteLine("Insert a slide");
                PowerPoint.Slide oSlide = oPre.Slides.Add(1,
                                                          PowerPoint.PpSlideLayout.ppLayoutText);

                Console.WriteLine("Add some texts");
                oSlide.Shapes[1].TextFrame.TextRange.Text =
                    "All-In-One Code Framework";

                // Save the presentation as a pptx file and close it.

                Console.WriteLine("Save and close the presentation");

                string fileName = Path.GetDirectoryName(
                    Assembly.GetExecutingAssembly().Location) + "\\Sample2.pptx";
                oPre.SaveAs(fileName,
                            PowerPoint.PpSaveAsFileType.ppSaveAsOpenXMLPresentation,
                            Office.MsoTriState.msoTriStateMixed);
                oPre.Close();

                // Quit the PowerPoint application.

                Console.WriteLine("Quit the PowerPoint application");
                oPowerPoint.Quit();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Solution2.AutomatePowerPoint throws the error: {0}",
                                  ex.Message);
            }
        }
        private void cmbDictionary_SelectedIndexChanged(object sender, EventArgs e)
        {
            dictionaryName = cmbDictionary.SelectedItem.ToString();
            location = api.getDictionary(dictionaryName).Slide_URL;
            presentation = Globals.ThisAddIn.Application.ActivePresentation;
            presentation.Close();
            presentation = Globals.ThisAddIn.Application.Presentations.Open(location);
            presentation = Globals.ThisAddIn.Application.ActivePresentation;

            txtOldName.Text = dictionaryName;
            pnlDictionary.Enabled = false;
            pnlRenameSlide.Enabled = true;
            pnlRenameDictionary.Enabled = true;
        }
Example #30
0
        public void EndPresentation()
        {
            if (pPre != null && pPre.SlideShowWindow.View.CurrentShowPosition > 1)
            {
                pPre.SlideShowWindow.View.Exit();
                pPre = null;
                //pPre.SlideShowWindow.View.EndNamedShow();
                //pPre.Close();
                //pApp.Quit();

                //SPD BGFIX: killing the app for ease
                Application.Exit();
            }
        }
Example #31
0
        private PowerPoint.CustomLayout GetCustomLayout(PowerPoint.Presentation ppPresentation, string slideLayout)
        {
            PowerPoint.CustomLayout ppCustomLayout = null;

            foreach (PowerPoint.CustomLayout customLayout in ppPresentation.SlideMaster.CustomLayouts)
            {
                if (customLayout.Name == slideLayout)
                {
                    return(customLayout);
                }
            }

            return(ppCustomLayout);
        }
Example #32
0
        /// <summary>
        /// Sets the visibility of all shapes in the current
        /// presentation to reflect the combination of the current presentation's mode
        /// and the shape's visibility.
        /// </summary>
        private void ConfigureVisibility()
        {
            // Get the current presentation.
            PowerPoint.Presentation presentation = this.myPPT.GetActivePresentation();
            if (presentation == null)
            {
                return;
            }

            foreach (PowerPoint.Slide slide in presentation.Slides)
            {
                this.ConfigureVisibility(slide.Shapes);
            }
        }
Example #33
0
        private ICollection GetRestrictedShapes(PowerPoint.Presentation presentation)
        {
            IDictionary rsTable = this.GetRestrictedTable(presentation);

            // Check correctness of the cache.
            bool correct = true;
            ArrayList /* of ShapeKey */ keysToDelete = new ArrayList();

            foreach (PPTLibrary.ShapeKey key in rsTable.Keys)
            {
                PowerPoint.Shape    shape  = (PowerPoint.Shape)rsTable[key];
                PPTLibrary.ShapeKey oldKey = key;
                try     { oldKey = new PPTLibrary.ShapeKey(shape, this.myPPT.GetSlideFromShape(shape).SlideID); }
                catch (System.Runtime.InteropServices.COMException)
                {
                    // Shape does not exist, delete it from the cache.
                    keysToDelete.Add(key);
                    continue;
                }
                if (!key.Equals(oldKey) || !this.IsRestricted(shape))
                {
                    correct = false;
                    break;
                }
            }

            if (!correct)
            {
                this.RebuildCache(presentation);
                rsTable = this.GetRestrictedTable(presentation);
            }
            else
            {
                foreach (PPTLibrary.ShapeKey key in keysToDelete)
                {
                    rsTable.Remove(key);
                }
            }

            ArrayList shapes = new ArrayList();

            // No need to test if objects exist since non-existant objects have
            // just been weeded out.
            foreach (PowerPoint.Shape shape in rsTable.Values)
            {
                shapes.Add(shape);
            }
            return(shapes);
        }
Example #34
0
        private static void SelectFragment(PowerPoint.Presentation ppt, string fragment)
        {
            string[] sheet_cell = fragment.Split('!');

            if (!Int32.TryParse(sheet_cell[0], out int pageNo))
            {
                Forms.MessageBox.Show($"Slide number {sheet_cell[0]} is not a number."
                                      , TITLE, Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Exclamation);
                return;
            }
            if (pageNo <= 0 || ppt.Slides.Count < pageNo)
            {
                Forms.MessageBox.Show($"Slide number {pageNo} is out of range. the presentation has only {ppt.Slides.Count} slide[s]."
                                      , TITLE, Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                ppt.Application.ActiveWindow.View.GotoSlide(pageNo);
                if (sheet_cell.Length <= 1)
                {
                    return;
                }

                string[] names = sheet_cell[1].Split(',');
                PowerPoint.SlideRange slide = ppt.Slides.Range(pageNo);
                foreach (string name in names)
                {
                    new Action(() =>
                    {
                        for (int i = 0; i < slide.Shapes.Count; i++)
                        {
                            PowerPoint.Shape shape = slide.Shapes[1 + i];
                            if (shape.Name.Equals(name))
                            {
                                shape.Select(MsoTriState.msoFalse);
                                return;
                            }
                        }
                        Forms.MessageBox.Show($"Object \"{name}\" not found", TITLE, Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Exclamation);
                    })();
                }
            }
            catch (COMException ex)
            {
                Forms.MessageBox.Show(ex.Message + ex.StackTrace, TITLE, Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Exclamation);
            }
        }
Example #35
0
        //<Snippet1>
        private void AddCustomXmlPartToPresentation(PowerPoint.Presentation presentation)
        {
            string xmlString =
                "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
                "<employees xmlns=\"http://schemas.microsoft.com/vsto/samples\">" +
                "<employee>" +
                "<name>Karina Leal</name>" +
                "<hireDate>1999-04-01</hireDate>" +
                "<title>Manager</title>" +
                "</employee>" +
                "</employees>";

            Office.CustomXMLPart employeeXMLPart =
                presentation.CustomXMLParts.Add(xmlString, missing);
        }
Example #36
0
 private void CentrePictures(PowerPoint.Presentation ppPresentation)
 {
     foreach (PowerPoint.Slide slide in ppPresentation.Slides)
     {
         // centre picture
         foreach (PowerPoint.Shape shape in slide.Shapes)
         {
             if (shape.Type == MsoShapeType.msoPicture)
             {
                 shape.Left = SlideWidthCentre - (shape.Width / 2);
                 shape.Top  = SlideHeightCentre - (shape.Height / 2);
             }
         }
     }
 }
        /// <summary>
        /// Converts ppts to PDF documents asynchronously
        /// </summary>
        /// <param name="ppApp">The PowerPoint application</param>
        /// <param name="info">A PptInfo object of the file to be converted to pdf</param>
        /// <param name="newPath">Full path of the converted file</param>
        private Task ppConvertAsync(PP.Application ppApp, PptInfo info, string destDir)
        {
            return(Task.Run(() => {
                // open presentation in PP in the bg
                PP.Presentation pres = ppApp.Presentations.Open(info.Path, WithWindow: Microsoft.Office.Core.MsoTriState.msoFalse);

                // build path for converted file
                string newPath = Path.Combine(new[] { destDir, Path.ChangeExtension(Path.GetFileName(info.Path), "pdf") });

                // convert to pdf
                pres.SaveAs(newPath, PP.PpSaveAsFileType.ppSaveAsPDF);
                pres.Close();
                Util.ReleaseComObject(pres);
            }));
        }
        /// <summary>
        /// Saves the document out with the appropriate new filename and format.
        /// Also does any special handling such as accepting/rejecting changes
        /// before saving.
        /// </summary>
        private void SaveDocument()
        {
            m_presentation.SaveAs(m_newFileName, m_newFormatType, MS_FALSE);

            try
            {
                m_presentation.Close();
            }
            catch (Exception e)
            {
                Logger.LogError(m_log, "Failed to close PowerPoint presentation", e);
            }

            m_presentation = null;
        }
Example #39
0
 internal static void RemoveNotes(PowerPoint.Presentation presentation)
 {
     foreach (PowerPoint.Slide slide in presentation.Slides)
     {
         if (slide.HasNotesPage == Office.MsoTriState.msoTrue)
         {
             PowerPoint.Shape notes = getPlaceholder(PowerPoint.PpPlaceholderType.ppPlaceholderBody, slide.NotesPage.Shapes);
             if (notes.HasTextFrame == Office.MsoTriState.msoTrue)
             {
                 notes.TextFrame.DeleteText();
                 notes.TextFrame2.DeleteText();
             }
         }
     }
 }
Example #40
0
        public PowerpointLoader(String FilePath)
        {
            this.FilePath = FilePath;
            MsoTriState ofalse = MsoTriState.msoFalse;

            //MsoTriState otrue = MsoTriState.msoTrue;
            if (PowerPointApplication == null)
            {
                PowerPointApplication = new PowerPoint.Application();
            }
            PowerPointApplication.Presentations.Open(@FilePath, ofalse, ofalse, ofalse);
            int currrent = PowerPointApplication.Presentations.Count;

            PowerPointPresentation = PowerPointApplication.Presentations[currrent];
        }
Example #41
0
        protected override OfficeDocument Open(System.IO.FileInfo file)
        {
            string filedocxtoOpen = file.FullName;

            if (file.Extension.Equals(HtmlExtension, StringComparison.CurrentCultureIgnoreCase) || file.Extension.Equals(".htm", StringComparison.CurrentCultureIgnoreCase))
            {
                FileInfo docFile = new FileInfo(file.FullName.Replace(file.Extension, ".ppt"));
                if (docFile.Exists)
                {
                    filedocxtoOpen = docFile.FullName;
                }
            }
            PowerPoint.Presentation presentation = application.Presentations.Open(filedocxtoOpen, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue);
            return(new PowerPoint2007OfficeDocument(presentation));
        }
Example #42
0
        public void Clean()
        {
            if (this.presentation != null && this.powerpoint != null)
            {
                //this.presentation.Close();
                //Marshal.ReleaseComObject(this.presentation);

                //this.powerpoint.Quit();
                //Marshal.ReleaseComObject(this.powerpoint);

                this.powerpoint = null;
                this.presentation = null;

                this.KillPowerPoint();
            }
        }
 public void Setup()
 {
     CultureUtil.SetDefaultCulture(CultureInfo.GetCultureInfo("en-US"));
     try
     {
         App = new PowerPoint.Application();
     }
     catch (COMException)
     {
         // in case a warm-up is needed
         App = new PowerPoint.Application();
     }
     Pres = App.Presentations.Open(
         PathUtil.GetDocTestPath() + GetTestingSlideName(),
         WithWindow: MsoTriState.msoFalse);
     PpOperations = new UnitTestPpOperations(Pres, App);
 }
Example #44
0
        public void Parse(object src, object dest)
        {
            if (src == null || string.IsNullOrEmpty(src.ToString()))
            {
                throw new ArgumentNullException("源文件不能为空");
            }
            if (dest == null || string.IsNullOrEmpty(dest.ToString()))
            {
                throw new ArgumentNullException("目标路径不能为空");
            }
            try
            {
                presentation = pptApp.Presentations.Open(src.ToString(), Microsoft.Office.Core.MsoTriState.msoTrue
                , Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);

                presentation.ExportAsFixedFormat(dest.ToString(), PpFixedFormatType.ppFixedFormatTypePDF, PpFixedFormatIntent.ppFixedFormatIntentScreen
                    , Microsoft.Office.Core.MsoTriState.msoFalse, PpPrintHandoutOrder.ppPrintHandoutHorizontalFirst, PpPrintOutputType.ppPrintOutputSlides
                    , Microsoft.Office.Core.MsoTriState.msoFalse, null, PpPrintRangeType.ppPrintAll, string.Empty, false
                    , false, false, true, true, missing);
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (presentation != null)
                {
                    presentation.Close();
                    presentation = null;
                }

                if (pptApp != null)
                {
                    pptApp.Quit();
                    pptApp = null;
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
Example #45
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;
            }
        }
Example #46
0
        //关闭Powerpoint文档
        public static void ClosePowerPoint()
        {
            if (ppt != null)
            {
                try
                {
                    ppt.SaveAs(pptPath, PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, True);
                    ppt.Close();
                    ppt = null;

                    powerpoint.Quit();
                    powerpoint = null;

                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
                GC.Collect();
            }
        }
Example #47
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
     }
 }
        public bool GetOpenPpt()
        {
            bool success = false;
            try
            {
                // Get Running PowerPoint Application object
                pptApplication = Marshal.GetActiveObject("PowerPoint.Application") as PowerPoint.Application;
            }
            catch
            {

            }

            if (pptApplication != null)
            {
                success = true;

                // Get Presentation Object
                presentation = pptApplication.ActivePresentation;
                // Get Slide collection object
                slides = presentation.Slides;
                // Get Slide count
                slidesCount = slides.Count;
                // Get current selected slide
                try
                {
                    // Get selected slide object in normal view
                    slide = slides[pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber];
                }
                catch
                {
                    // Get selected slide object in reading view
                    slide = pptApplication.SlideShowWindows[1].View.Slide;
                }
            }

            return success;
        }
Example #49
0
 //注销PPT资源
 public void ClosePPT()
 {
     try
     {
         ppt.Close();
         ppt = null;
         //if (powerpoint.Presentations.Count == 0)
         //{
             powerpoint.Quit();
             powerpoint = null;
         //}
     }
     catch { }
     GC.Collect();
 }
Example #50
0
 //打开文件
 void openFile(string file)
 {
     fileName = file.Substring(file.LastIndexOf('\\') + 1);
     powerpoint = new PowerPoint.ApplicationClass();
     powerpoint.Visible = True;                              //一定要放在Open前!
     ppt = powerpoint.Presentations.Open(file, False, True, True);
 }
Example #51
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Get Running PowerPoint Application object
                pptApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("PowerPoint.Application") as PPt.Application;
            }
            catch
            {

            }
            if (pptApplication != null)
            {
                // Get Presentation Object
                presentation = pptApplication.ActivePresentation;
                // Get Slide collection object
                slides = presentation.Slides;
                // Get Slide count
                slidescount = slides.Count;
                // Get current selected slide
                try
                {
                    // Get selected slide object in normal view
                    slide = slides[pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber];
                }
                catch
                {
                    // Get selected slide object in reading view
                    slide = pptApplication.SlideShowWindows[1].View.Slide;
                }
            }
        }
Example #52
0
 //结束评分
 void dispose()
 {
     try
     {
         stuPpt.Close();
         ansPpt.Close();
         stuPpt = null;
         ansPpt = null;
         if (powerpoint.Presentations.Count == 0)
         {
             powerpoint.Quit();
             powerpoint = null;
         }
     }
     catch { }
     GC.Collect();
 }
Example #53
0
 //打开文件
 public void openFile(string stu, string ans, string xml)
 {
     powerpoint = new PowerPoint.ApplicationClass();
     //powerpoint.Visible = True;
     powerpoint.Activate();
     //powerpoint.Visible = False;
     //stuPpt = powerpoint.Presentations.Add(True);
     //ansPpt = powerpoint.Presentations.Add(True);
     stuPpt = powerpoint.Presentations.Open(stu, False, True, True);
     ansPpt = powerpoint.Presentations.Open(ans, False, True, True);
     oxml = new OfficeXML(xml);
     getPoint(oxml);
 }
Example #54
0
 /// <summary>Constructor</summary>
 /// <param name="presentation">a reference to the active presentation</param>
 public Metadata(PPT.Presentation presentation)
 {
     _ppt = presentation;
 }
        /// <summary>
        /// Handles button for creating dictionaries
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdCreateDictionary_Click(object sender, EventArgs e)
        {
            dictionaryName = txtDictionary.Text;
            //dictionaryName = txtDictionary.Text.ToLower(); ?

            if (!api.dictionary_exists(dictionaryName))
            {
                if (dictionaryName != "")
                {

                    presentation = Globals.ThisAddIn.Application.ActivePresentation;

                    location = filePath + "\\" + dictionaryName;

                    presentation.SaveAs(location, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Microsoft.Office.Core.MsoTriState.msoTrue);
                    presentation.Save();

                    api.addDictionary(dictionaryName, location + ".pptx");

                    MessageBox.Show("Dictionary added. You may now add keywords to the dictionary");

                    pnlAssociations.Enabled = true;
                    pnlDictionary.Enabled = false;

                }
                else
                {
                    MessageBox.Show("Dictionary name cannot be blank - Please enter a dictionary name");
                }
            }
            else
            {
                MessageBox.Show("\""+ dictionaryName + "\"" + " dictionary already exists");
            }
        }
Example #56
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();
        }
        public void RunPresentation(string file)
        {
            if (Presentation == null)
            {
                PowerPoint._Application pApp = new PowerPoint.Application();

                // use existing (already opened) ppt file
                if (pApp.Presentations.Count > 0)
                {
                	Presentation = pApp.Presentations[1];
                }
                else // open the file
                {
                    try
                    {
                        Presentation = pApp.Presentations.Open(
                            file, Office.MsoTriState.msoFalse,
                            Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue);
                    }
                    catch (System.Exception ex)
                    {
                        Debug.WriteLine("PPT open error: " + ex);
                    }
                        
                        
                    
                }
            }

            //Start playing presentation.
            Retry.Do(RunPpt, TimeSpan.FromSeconds(3));
        }
Example #58
0
 public static String next()
 {
     String eString = "";
     if (objpre != null)
     {
         try
         {
             objpre.SlideShowWindow.View.Next();
             if (0==objpre.SlideShowWindow.View.GetClickIndex())
             {
                 intNowPage++;
             }
             intPer = Convert.ToInt32(intNowPage*100 / intPageSize);
             eString = "next()执行成功 ";
             Debug.WriteLine(eString);
         }
         catch (Exception)
         {
             try
                {
                 objpre.Close();
                 objpre = null;
                 eString = "next()执行完成  " ;
             }
             catch(Exception)
             {
                 objpre = null;
                 eString = "next()执行异常,已自动重置播放的幻灯片  " ;
             }
         }
     }
     else
     {
         eString = "没有已打开的PPT文件 " ;
     }
     return eString;
 }
Example #59
0
        //结束评分
        private void dispose()
        {
            try
            {
                stuPpt.Close();
                ansPpt.Close();
                stuPpt = null;
                ansPpt = null;
                if (powerpoint.Presentations.Count == 0)
                {
                    powerpoint.Quit();
                    powerpoint = null;
                }
            }
            catch { }
            GC.Collect();

            System.Diagnostics.Process[] pro = System.Diagnostics.Process.GetProcesses();
            foreach (System.Diagnostics.Process pro1 in pro)
                if (pro1.ProcessName.ToLower() == "powerpnt")
                    pro1.Kill();
        }
Example #60
0
        /// <summary>
        /// 自动播放PPT文档.
        /// </summary>
        /// <param name="filePath">PPT文件路径.</param>
        /// <param name="playTime">翻页的时间间隔.【以秒为单位】</param>
        /// <param name="timeout">超时限制【以秒为单位】</param>
        public void PPTAuto(object presSet, int playTime, int timeout)
        {
            iSlideShowTime = playTime;
            objPresSet = (POWERPOINT.Presentation)presSet;

            if (timeout > 0 && objPresSet.Slides.Count * playTime > timeout)
            {
                objApp_SlideShowNextSlide(null);
                return;
            }

            objApp = objPresSet.Application;
            iSlideIndex = 0;
            try
            {
                // 自动播放的代码(开始)
                int Slides = objPresSet.Slides.Count;
                int[] SlideIdx = new int[Slides];
                for (int i = 0; i < Slides; i++) { SlideIdx[i] = i + 1; };
                objSldRng = objPresSet.Slides.Range(SlideIdx);
                objSST = objSldRng.SlideShowTransition;
                //关闭助手显示
                objApp.Assistant.On = false;
                objApp.Assistant.Visible = false;
                //设置翻页的时间.
                objSST.AdvanceOnTime = OFFICECORE.MsoTriState.msoCTrue;
                objSST.AdvanceTime = playTime;
                //翻页时的特效!
                objSST.EntryEffect = POWERPOINT.PpEntryEffect.ppEffectCircleOut;
                //Run the Slide show from slides 1 thru 3.
                objSSS = objPresSet.SlideShowSettings;
                objSSS.StartingSlide = 1;
                objSSS.EndingSlide = Slides;
                objApp.SlideShowNextSlide += new POWERPOINT.EApplication_SlideShowNextSlideEventHandler(objApp_SlideShowNextSlide);

                hook.Hook_Clear();
                hook.Hook_Start();

                objSSS.Run();
            }
            catch
            {
                hook.Hook_Clear();
            }
        }