日期:2014-05-18  浏览次数:20370 次

【求大家帮忙看看代码】C#读取PPT
我想实现查找PPT内容的程序
我的程序如下:

  protected   void   Button3_Click(object   sender,   EventArgs   e)
        {
                bool   b   =   false;
                string   file   =   @ "E:\Net实训\Lesson9.ppt ";     //搜索文件

                Microsoft.Office.Interop.PowerPoint.Application   pptApp   =   new   Microsoft.Office.Interop.PowerPoint.ApplicationClass();
                Microsoft.Office.Interop.PowerPoint.Presentation   pptPre   =   pptApp.Presentations.Open(file,
                    Microsoft.Office.Core.MsoTriState.msoTrue,
                    Microsoft.Office.Core.MsoTriState.msoFalse,
                    Microsoft.Office.Core.MsoTriState.msoFalse);
                Microsoft.Office.Interop.PowerPoint.Slides   mySlides   =   pptPre.Slides;

                string   strSearch   =   "多线程 ";     //搜索内容

                Microsoft.Office.Interop.PowerPoint.TextRange   oText   =   null;
                foreach   (Microsoft.Office.Interop.PowerPoint.Slide   slide   in   pptPre.Slides)
                {
                        foreach   (Microsoft.Office.Interop.PowerPoint.Shape   shape   in   slide.Shapes)
                        {
                                oText   =   shape.TextFrame.TextRange.Find(strSearch,   0,
                                Microsoft.Office.Core.MsoTriState.msoFalse,
                                Microsoft.Office.Core.MsoTriState.msoTrue);

                                if   (oText   !=   null)
                                {
                                        b   =   true;
                                        break;
                                }
                                else