日期:2014-05-18  浏览次数:20746 次

用过jacob的兄弟进来看
public   void   createDocument(){
      Dispatch   documents=MsWordApp.getProperty( "Documents ").toDispatch();
      //Dispatch   documents=Dispatch.get(MsWordApp, "Documents ").toDispatch();//the   same   as   top   line
      document=Dispatch.call(documents, "Add ").toDispatch();
      }
      public   void   openDocuemnt(String   filename){
      Dispatch   documents=Dispatch.get(MsWordApp, "Documents ").toDispatch();
      document=Dispatch.call(documents, "Open ",filename).toDispatch();
      }
      public   void   insertText(String   textToInsert){
      Dispatch   selection=Dispatch.get(MsWordApp, "Selection ").toDispatch();
      Dispatch.put(selection, "Text ",textToInsert);//not   call
      Dispatch.call(selection, "MoveRight ",new   Variant(1),new   Variant(1));//取消选择
      }
我的问题是
1.dispatch是什么类型的对象,我的理解是非java   非com对象,是一个两者联系的通用对象?
2.用jacob我能实现在word文档中查找并提取出查找到的内容,谁能帮我写出提取整个word文档的函数啊.
3.如上代码片段,之上的selection对象,document对象是来自于win32api中的对象句柄吗,那么 "Text ", "MoveRight "这些属性从什么地方能查到,因为我想得到更多的功能.操作word.
4.感谢兄弟帮忙,每问10分吧.


------解决方案--------------------
看自带的Samples