`
harry
  • 浏览: 180096 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

使用JACOB控制Powerpoint

    博客分类:
  • Java
阅读更多

什么是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();

}

}

相关资料

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics