ActiveXComponent app = new ActiveXComponent("Word.Application"); //启动word
String inFile = "C:\\TEMP\\test.doc";
app.setProperty("Visible", new Variant(false)); //设置word不可见
Dispatch docs = app.getProperty("Documents").toDispatch();
Dispatch doc = Dispatch.invoke(docs,"Open",Dispatch.Method,
new Object[] { inFile, new Variant(false),new Variant(false) }, new int[1]).toDispatch();
/*方法1: 通过查找文本取页码*/
Dispatch selection = app.getProperty("Selection").toDispatch();//获得对Selection组件
Dispatch.call(selection, "HomeKey", new Variant(6));//移到开头
Dispatch find = Dispatch.call(selection, "Find").toDispatch();//获得Find组件
Dispatch.put(find, "Text", "二、成果简介"); //查找字符串"二、成果简介"
Dispatch.call(find, "Execute"); //执行查询
String pages = Dispatch.call