1 Reply Latest reply: Jun 25, 2009 1:19 AM by 843830 RSS

    Can a Java App open and populate an MSWord or MSExcel document?

    843830
      I am new to Java and would like to know if it is possible to create a pointer to Microsoft Word that lets the Java app insert and control text and images in Microsoft Word (or Excel).

      As an example....

      In Visual Basic, a project reference to MSWord9.olb is established and then a pointer is created using code like this:

      Set wdApp = CreateObject("Word.Application")

      This pointer (wdApp) can then be used to create documents, add text, change styles, create tables, etc.

      Any help is appreciated....
        • 1. Re: Can a Java App open and populate an MSWord or MSExcel document?
          843830
          Hi SunnyCalifornia,

          If you have JDK 6, you can do this :
          import java.awt.Desktop;
          ....
          ....
          Desktop dsk;
          if (Desktop.isDesktopSupported() {
              dsk = Desktop.getDesktop();
              dsk.open(new File("the path of your Windows application executable"));
          } else {
              System.out.println("Desktop is not supported by your system !");
          }
          But, your Java application won't be able to interfer with components or utilities of Windows applications.