用编程的方式根据对象模型很容易实现在word、excel文档中搜索文本,在powerpoint里面也同样如此,使用对象模型有助于我们了解office的文档结构。
搜索的思路和方法基本是一样的,用powerpoint应用程序对象打开指定的文档,用文档对象获取文档,再使用合适的对象将文档分割成搜索范围适中的对象进行搜索。
打开powerpoint的vba帮助文档vbapp10.chm,根据对象模型图,很容易找到我们需要的几个集合和对象:application、presentations、presentation、slides、slide、textframe、textrange。其中presentation代表一个 powerpoint 文档,slide表示powerpoint文档中的单张幻灯片,textframe是幻灯片上的文本框,textrange是文本框中的文本。
打开powerpoint文档:
string filename="";
powerpoint.application pa=new powerpoint.applicationclass();
powerpoint.presentation pp=pa.presentations.open(filename,
microsoft.office.core.msotristate.msotrue,
microsoft.office.core.msotristate.msofalse,
microsoft.office.core.msotristate.msofalse);
open()方法的第三个参数在帮助文档中的说明如下:
untitled 可选。msotristate 类型。指定文件是否有标题。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器