aspose file tools*
The moose likes Java in General and the fly likes Java + COM (Ms Word) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java + COM (Ms Word)" Watch "Java + COM (Ms Word)" New topic
Author

Java + COM (Ms Word)

Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
Hi. Does anybody have any experience with using COM objects with Java? I specifically need to open word, open a document and do some stuff with it. What libraries have you used? Any tutorials?

Regards,
RafaƂ
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Apache POI is the API people usually use to do this.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
If you're all set to use COM instead of a pure Java solution, here are a few libraries that can help with that: http://faq.javaranch.com/java/JavaIntermediateFaq#callingCom


Ping & DNS - my free Android networking tools app
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
Hi guys,
thanks for your answers.
@Paul: as far as I know, POI allows me to manipulate the documents from Java code. This is not what I need to do. I will give the main use case - the user creates a Word template file (dot) with fields from a data source. Then, using our application, they will search for some data, export it do a data source that Word supports (like RTF file for instance), and will open Word with the template and the data source merged. That's it, we don't have to do anything else.
Please, if I am wrong don't hesitate to tell me, if there is a simpler approach I will most certainly consider it. Please note that opening Word is a requirement. If Word supported command line switches that take a tempalte and a data source as input, I could simply fire it up with the usual Java Process API, but I did some research and it looks like that using Word as a COM object is the only way to go. Also, I had some bad experiences with POI and Docs some time ago (it was fine for Xls though).

@Ulf: thanks for the link. Currently I am playing a bit with JACOB, and it looks fine. I didn't know about Jawin and the IBM solution, will take a look at that, thanks.

Regards,
Raf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java + COM (Ms Word)