当前位置: 代码迷 >> C# >> 关于调用powerpoint
  详细解决方案

关于调用powerpoint

热度:101   发布时间:2016-05-05 04:34:52.0
求助关于调用powerpoint
   最近自己在做一个手机通过wifi控制电脑ppt播放,然后基本的播放暂停还有翻页功能都实现了,现在想知道com里面的那个powerpoint的接口怎么获取最近打开的ppt文件,还有当打开新的ppt文件的事件要怎么监听等等,希望能给个思路

------解决思路----------------------


  public static void ShowPPT(string strTemplate)
        {
            PowerPoint.Application objApp;
            PowerPoint.Presentations objPresSet;
            PowerPoint._Presentation objPres;
            PowerPoint.Slides objSlides;                                   
            PowerPoint.SlideShowWindows objSSWs;            
            PowerPoint.SlideShowSettings objSSS;
            PowerPoint.SlideRange objSldRng;
            bool bAssistantOn;
            try
            {
                objApp = new Microsoft.Office.Interop.PowerPoint.Application();
                objApp.Visible = MsoTriState.msoTrue;
                objPresSet = objApp.Presentations;
                objPres = objPresSet.Open(strTemplate, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
                objSlides = objPres.Slides;
                //Modify the slide show transition settings for all 3 slides in //the presentation.
                int[] SlideIdx = new int[3];

                for (int i = 0; i < 3; i++) SlideIdx[i] = i + 1;
                objSldRng = objSlides.Range(SlideIdx);
                //objSST = objSldRng.SlideShowTransition;
                //objSST.AdvanceOnTime = MsoTriState.msoTrue;
                //objSST.AdvanceTime = 3;
                // objSST.EntryEffect = Microsoft.Office.Interop.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;
                }
                objPres.Close();
                objApp.Quit();
            }
            catch
            {

            }
            finally
            {
                //Close the presentation without saving changes and quit PowerPoint. 

            }
        }


------解决思路----------------------
这是播放PPT代码,using Microsoft.Office.Interop.PowerPoint;
------解决思路----------------------
监听的话,可监控PPT进程