jacob ppt转换成图片报错

心_行 发布于 2014/08/01 10:24
阅读 949
收藏 0

【领华为电脑包】容器化时代到来!跳转机分配问题终于“有救”了!>>>

错误:Exception in thread "main" com.jacob.com.ComFailException: Invoke of: SaveCopyAs
Source: Microsoft PowerPoint 2013  

Description: Presentation.SaveCopyAs : Invalid request.  Saving as an HTML presentation is not supported in this version of PowerPoint.

public static synchronized void ppt2Img(String inputFile,String pdfFile){
		System.out.println("ppt2PDF==========进入");
		ActiveXComponent app = null;
		try {
			 app = new ActiveXComponent("PowerPoint.Application");
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("--------------------");
		app.setProperty("Visible", true);
		Dispatch ppts = app.getProperty("Presentations").toDispatch();
		System.out.println("ppt2PDF==========准备打开ppt文档");
        System.out.println(new File(inputFile).exists());
        Dispatch ppt = Dispatch.call(ppts,
									"Open",
									inputFile,
									true,//ReadOnly
									true,//Untitled指定文件是否有标题
									true//WithWindow指定文件是否可见
									).toDispatch();
		System.out.println("ppt2PDF==========准备转换ppt文档");
		Dispatch.call(ppt,
					"SaveCopyAs",
					pdfFile,
					17//转换成jpg
					);
		System.out.println("ppt2PDF==========准备关闭ppt文档");		
		Dispatch.call(ppt, "Close");
		
		app.invoke("Quit");
		
	}

    public static void main(String[] args) {
        //word2PDF("D://aaa.docx","D://aaa.pdf");
        ppt2Img("D://t.pptx","D://ppt_img/a.jpg");
    }



加载中
0
心_行
心_行
已找到原因:我用的office2013,换成office2010就行了
返回顶部
顶部