Java bean word processing

Interface to control Microsoft® Word by java applications
Deutsche Version

Would you like to load Microsoft® Word, to create a new document and to serve bookmarks by your java application? There is a free java class for you here!

Use sample
Just code this:
WordProcessing.typeTextAtBookmark("AddressLine1", "O'Reilly & Associated, Inc.");
WordProcessing.typeTextAtBookmark("AddressLine2", "Mr Miller");
WordProcessing.typeTextAtBookmark("AddressLine3", "101 Moris Street");
WordProcessing.typeTextAtBookmark("AddressLine4", "Sebastopol, CA 95472-9902");
WordProcessing.typeTextAtBookmark("Salutation", "Dear Mr Miller,");

What’s that bean good for?

If users work e.g. on customer files they want to contact them with the word processing they are used to. And that’s what this bean does:

There may be programmers who will object that this initiative contradicts the platform independent intention. Let me argue:
  1. Microsoft® Word is a de-facto standard which many don't want to do without.
  2. Anybody who offers an analogue control for other operating systems can be sure of a link from this site.

Method overview
createNewDocumentFromTemplate(String templateName) Creates a new document based on the desired template.
createNewDocumentFromTemplateToSelectByUser() Triggers to the template selection dialog and creates a new document based on the chosen template.
setNoteNotMatchingBookmarks(boolean noteNotMatchingBookmarks) Decides whether the user shall be informed that the template didn't include certain bookmarks.
typeTextAtBookmark(String bookmark, String textToType) Goes to the specified bookmark and types the desired text.
typeTextAtBookmark(String bookmark, String[] linesToType) Goes to the specified bookmark and types the desired lines with line feed.
changeDocumentDirectory(String documentDirectory) Sets the document directory for future document saving.
saveDocumentAs(String documentName) Saves the active document using the indicated name (usually without extension).
saveDocumentAsAndClose(String documentName) Saves the active document using the indicated name and closes it.
closeDocument() Closes the active document.
printAndForget() Prints the document on the standard printer and closes the document without saving.
printToPrinterToSelectByUserAndForget() Triggers to the printer selection dialog, prints the document on the selected printer and closes the document without saving.
printAndForget(String printerName) Prints the document on the specified printer and closes the document without saving.
executeMacro(String macroName) Executes an arbitrary WordBasic macro.
quitApplication() Quits the word processing application
exec() Starts the execution of  the above instructions. (This stacking is particularly helpful at large numbers of standard letters.)

Free Download
WordAPI.exe (V1.4, 354 k) Word processing driver for Windows 7, Vista (32 / 64 Bit), XP, 2000, NT - last update 10/14/04 (checkout source code) Java class source to access the driver Template with bookmarks as used in the example above. (V1.3, 166 k, optional) Server variant - with protocol output to log file.

More Download for Advanced Usage - Open Source!

For those who want to make use of our base work more largely: All our components are available as Open Source now! Sample application of the framework is among others an address administration using the WordProcessing class for writing single and standard letters based on an address selection. -> More information and download