读书人

【求大伙帮忙看看代码】C#读取PPT

发布时间: 2011-12-14 23:20:17 作者: rapoo

【求大家帮忙看看代码】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
b = false;

}


}
if (b)
Response.Write( "Find ");

}

-------------------------
错误:TextFrame (unknown member) : Invalid request. This type of shape cannot have a TextRange

大家帮忙解决下啊 马上周末了 任务要完成啊! 谢谢大家了

[解决办法]
帮顶

读书人网 >asp.net

热点推荐