示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Set license key to use GemBox.Presentation in Free mode.
            ComponentInfo.SetLicense("FREE-LIMITED-KEY");
            var presentation = new PresentationDocument();
            var slide        = presentation.Slides.AddNew(SlideLayoutType.Custom);
            var textBox      = slide.Content.AddTextBox(0, 0, 5, 5, LengthUnit.Centimeter);

            textBox.AddParagraph().AddRun("Hello World!");



            // Save to PPTX and PDF files.
            presentation.Save("Presentation.pptx");
            //open it
            var app  = new PowerPoint.Application();
            var pres = app.Presentations;
            var file = pres.Open(@"C:\Users\real1\Desktop\Crypto_project\Audit\Audit\bin\Debug\Presentation.pptx", MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoFalse);

            PowerPoint.SlideShowSettings slideSetting = file.SlideShowSettings;
            slideSetting.Run();

            PowerPoint.SlideShowWindows slideShowWindows = app.SlideShowWindows;
            while (true)
            {
                if (slideShowWindows.Count <= 0)
                {
                    break;
                }
                System.Threading.Thread.Sleep(100);
            }
        }
示例#2
0
        /// <summary>
        /// 自动播放PPT文档.
        /// </summary>
        /// <param name="filePath">PPTy文件路径.</param>
        /// <param name="playTime">翻页的时间间隔.【以秒为单位】</param>
        public void PPTAuto(string filePath, int playTime)
        {
            //防止连续打开多个PPT程序.
            if (this.objApp != null)
            {
                return;
            }

            objApp     = new POWERPOINT.Application();
            objPresSet = objApp.Presentations.Open(filePath, OFFICECORE.MsoTriState.msoCTrue, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse);

            // 自动播放的代码(开始)
            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;
            //设置翻页的时间.
            objSST.AdvanceOnTime = OFFICECORE.MsoTriState.msoCTrue;
            objSST.AdvanceTime   = playTime;
            //翻页时的特效!
            objSST.EntryEffect = POWERPOINT.PpEntryEffect.ppEffectCircleOut;

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

            //Run the Slide show from slides 1 thru 3.
            objSSS = objPresSet.SlideShowSettings;
            objSSS.StartingSlide = 1;
            objSSS.EndingSlide   = Slides;
            objSSS.Run();

            //Wait for the slide show to end.
            objSSWs = objApp.SlideShowWindows;
            while (objSSWs.Count >= 1)
            {
                System.Threading.Thread.Sleep(playTime * 100);
            }

            this.objPresSet.Close();
            this.objApp.Quit();
        }
示例#3
0
        public void Save()
        {
            //Prevent Office Assistant from displaying alert messages:
            bool bAssistantOn = application.Assistant.On;

            application.Assistant.On = false;

            //Run the Slide show from slides 1 thru 3.
            slideSettings = pptPresentation.SlideShowSettings;
            slideSettings.StartingSlide = 1;
            slideSettings.EndingSlide   = 3;
            slideSettings.Run();

            //Wait for the slide show to end.
            slideWindows = application.SlideShowWindows;
            while (slideWindows.Count >= 1)
            {
                System.Threading.Thread.Sleep(100);
            }

            //Reenable Office Assisant, if it was on:
            if (bAssistantOn)
            {
                application.Assistant.On      = true;
                application.Assistant.Visible = false;
            }

            //Close the presentation without saving changes and quit PowerPoint.
            pptPresentation.Close();
            application.Quit();

            Thread.Sleep(200);
            string fileName = string.Format("朗开医疗体检报告[{0}][{1}].ppt", System.Net.Dns.GetHostName(), DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"));

            File.Copy(_fileName, Path.GetDirectoryName(_fileName) + "\\" + fileName);
        }
        public static void IncludeOthers(string path)
        {
            //Build Slide #2:
            //Add text to the slide title, format the text. Also add a chart to the
            //slide and change the chart type to a 3D pie chart.
            objSlide = objSlides.Add(objSlides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
            objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
            objTextRng.Text = "My Chart";
            objTextRng.Font.Name = "Comic Sans MS";
            objTextRng.Font.Size = 48;
            objChart = (Graph.Chart)objSlide.Shapes.AddOLEObject(150, 150, 480, 320,
              "MSGraph.Chart.8", "", MsoTriState.msoFalse, "", 0, "",
              MsoTriState.msoFalse).OLEFormat.Object;
            objChart.ChartType = Graph.XlChartType.xl3DPie;
            objChart.Legend.Position = Graph.XlLegendPosition.xlLegendPositionBottom;
            objChart.HasTitle = true;
            objChart.ChartTitle.Text = "Here it is...";

            //Build Slide #3:
            //Change the background color of this slide only. Add a text effect to the slide
            //and apply various color schemes and shadows to the text effect.
            objSlide = objSlides.Add(objSlides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutBlank);
            objSlide.FollowMasterBackground = MsoTriState.msoFalse;
            objShapes = objSlide.Shapes;
            objShape = objShapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect27,
              "The End", "Impact", 96, MsoTriState.msoFalse, MsoTriState.msoFalse, 230, 200);

            //Save the presentation to disk
            objPres.SaveAs(path,
                  PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
                  Microsoft.Office.Core.MsoTriState.msoFalse);
            //Modify the slide show transition settings for all 3 slides in
            //the presentation.
            int[] SlideIdx = new int[3];
            for (int k = 0; k < 3; k++) SlideIdx[k] = k + 1;
            objSldRng = objSlides.Range(SlideIdx);
            objSST = objSldRng.SlideShowTransition;
            objSST.AdvanceOnTime = MsoTriState.msoTrue;
            objSST.AdvanceTime = 3;
            objSST.EntryEffect = PowerPoint.PpEntryEffect.ppEffectBoxOut;

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

            //Run the Slide show from slides 1 thru 3.
            objSSS = objPres.SlideShowSettings;
            objSSS.StartingSlide = 1;
            objSSS.EndingSlide = 3;
            objSSS.Run();

            //Wait for the slide show to end.
            objSSWs = objApp.SlideShowWindows;
            while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);

            ////Reenable Office Assisant, if it was on:
            //if (bAssistantOn)
            //{
            //    objApp.Assistant.On = true;
            //    objApp.Assistant.Visible = false;
            //}

            //Close the presentation without saving changes and quit PowerPoint.
            //  objPres.Close();
            //  objApp.Quit();
        }
示例#5
0
        public void start_show1()
        {
            objSSWs = objApp.SlideShowWindows;

            objSlide.SlideShowTransition.AdvanceOnClick = MsoTriState.msoTrue;

            objApp.PresentationClose += new Microsoft.Office.Interop.PowerPoint.EApplication_PresentationCloseEventHandler(close_pres);
            // crate an instance with global hooks
            // hang on events

            //  actHook.KeyPress += new KeyPressEventHandler(key_pressed);
            objSSS = objPres.SlideShowSettings;
            objSSS.StartingSlide = (1);
            objSSS.EndingSlide = (1);
            objSSS.AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowManualAdvance;

            objSSS.Run();
            objPres.SlideShowWindow.View.GotoSlide(1);
        }