张小诺他爹 2021-05-24 12:13 采纳率: 0%
浏览 247

Can‘t get object clsid from progid

 /**
     * Initializes a JACOB object to start the office process to
     * manipulate the file.
     * <p>
     * 初始化一个JACOB对象启动office进程用来操作文件。
     * </p>
     */
    public JacobUtils() {
        // 线程启动,COM组件初始化
        ComThread.InitMTA(true);
        if (this.word == null) {
            long start = System.currentTimeMillis();
            // 启动word
            this.word = new ActiveXComponent("Word.Application");
            long end = System.currentTimeMillis();
            System.out.println("启动word总耗时:==========================" + (end - start));

            // true-可见打开word;false-不可见打开word
            this.word.setProperty("Visible", new Variant(false));
            // 禁用宏
            this.word.setProperty("AutomationSecurity", new Variant(3));
        }
        if (this.documents == null) {
            // 初始化word的所有文档窗口
        	this.documents = this.word.getProperty("Documents").toDispatch();
        }

    }

通过java -jar ***.jar命令启动jar报后jacob运行一切正常。但将jar包通过nssm工具注册到windows服务后,操作jacob则报如下异常。

com.jacob.com.ComFailException: Can't get object clsid from progid
    at com.jacob.com.Dispatch.createInstanceNative(Native Method) ~[jacob-1.19.jar!/:na]
    at com.jacob.com.Dispatch.<init>(Dispatch.java:99) ~[jacob-1.19.jar!/:na]
    at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58) ~[jacob-1.19.jar!/:na]
    at com.shiwen.zjbpm.common.util.JacobUtils.<init>(JacobUtils.java:98) ~[zjbpm-commons-0.0.1-SNAPSHOT.jar!/:0.0.1-SNAPSHOT]

  • 写回答

3条回答 默认 最新

  • CSDN专家-sinJack 2021-05-24 12:24
    关注

    Can't get object clsid from progid    这个是自己写的类吗

    评论

报告相同问题?

悬赏问题

  • ¥15 Windows 驱动 pcie问题
  • ¥15 用C语言完成一个复杂的游戏
  • ¥15 如何批量更改很多个文件夹里的文件名中包含文件夹名?
  • ¥50 MTK手机模拟HID鼠标出现卡顿
  • ¥20 求下下面这个数据结构代码
  • ¥15 路由器考试怎么办,有懂行的吗 ,eNSP
  • ¥20 前端 二进制文件流图片转化异常
  • ¥15 github上的这个C语言项目如何跑起来
  • ¥15 java 判断某个数 区间是否存在
  • ¥15 appium控制多个雷电模拟器问题