jacob在ActiveXComponent("Word.Application")初始化报错
public WordBean() throws Exception {
// if (word == null) {
// word = new ActiveXComponent("Word.Application");
// word.setProperty("Visible", new Variant(visible)); // 不可见打开word
//// word.setProperty("AutomationSecurity", new Variant(3)); // 禁用宏
// }
// if (documents == null)
// documents = word.getProperty("Documents").toDispatch();
if (this.word == null||word.m_pDispatch==0) {
ComThread.InitSTA();
/* 初始化应用所要用到的对象实例 */
this.word = new ActiveXComponent("Word.Application"); //当程序运行到这一步没有初始化成功就会爆出异常了
/* 设置Word文档是否可见,true-可见false-不可见 */
this.word.setProperty("Visible", new Variant(false));
/* 禁用宏 */
this.word.setProperty("AutomationSecurity", new Variant(3));
}
if (this.documents == null||documents.m_pDispatch==0) {
this.documents = word.getProperty("Documents").toDispatch();
}
}
每当运行到上面标红的那个地方就报错误,dll文件都放对了位置了! 原先用wps测试可以,卸载wps 安装了office2007然后就一直是这个地方出问题!
请教大神怎么解决