使用JACOB控制Powerpoint
关键字: JACOB Powerpoint什么是JACOB?
JACOB是一个JAVA和COM之间的桥接口。它使得你可以在Java中自动控制COM组件。它使用JNI通过本地调用COM和Win32程序接口。
除了JACOB,还需要什么?
要实现控制powerpoint除了了解JACOB怎么使用外,还需要了解powerpoint对象模型和powerpoint提供的接口。具体这方面的信息可以在MSDN上查找到。
简单实例
我实现了一个打开powerpoint程序并播放一个幻灯片的小程序,仅供大家参考。
/*
* PPTTest.java
* * Created on 2007年3月23日, 下午1:34
* * To change this template, choose Tools Template Manager
* and open the template in the editor.
*/
package jacobdemo;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
/**
* * @author Xiaofeng Wang
*/
public class PPTTest {
private static final String PPT_FILE = "D:\\ajax.ppt";
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// 新建一个powerpoint程序实例
ActiveXComponent ppt = new ActiveXComponent("PowerPoint.Application");
// 设置程序界面是否可见
ppt.setProperty("Visible", new Variant(true));
ActiveXComponent presentations
= ppt.getPropertyAsComponent("Presentations");
// 打开一个现有的 Presentation 对象
ActiveXComponent presentation =
presentations.invokeGetComponent("Open",new Variant(PPT_FILE),
new Variant(true));
// powerpoint幻灯展示设置对象
ActiveXComponent setting = presentation.getPropertyAsComponent("SlideShowSettings");
// 调用该对象的run函数实现全屏播放
setting.invoke("Run");
// 释放控制线程
ComThread.Release();
}
}
相关资料
发表评论
- 浏览: 17223 次
- 性别:

- 来自: 杭州

- 详细资料
搜索本博客
我的相册
共 7 张
最新评论
-
[摘]正确的创业者心态
ddd 写道》不过,如果这旧调本身不错,多弹几次,又有什么关系呢? 楼主看过古龙 ...
-- by spyker -
[摘]正确的创业者心态
》不过,如果这旧调本身不错,多弹几次,又有什么关系呢?楼主看过古龙的书,鉴定完毕 ...
-- by ddd -
无意中网上看到一篇关于ge ...
有很多必要的功能必须使用特定的插件,而这些插件又不是缺省安装必带的,所以用起来很 ...
-- by SteveGY -
无意中网上看到一篇关于ge ...
姜太公 写道可惜它的给关键字等加的颜色太难看。还有很多重复的gedit失败的地方 ...
-- by seen -
无意中网上看到一篇关于ge ...
可惜它的给关键字等加的颜色太难看。还有很多重复的
-- by 姜太公






评论排行榜