The problem is the Java program problem that converts M $ Word to XML in 9CBS (http://www.9cbs.net/expert/topic/1091/1091620.xml) POR (http://search.9cbs) .NET / EXPERT / TOPIC / 54/5406/2002/10/12 / 1091620.HTM). An easy way is set forth in detail below: 1. Under the Java-COM connection bridge Jacob (http://danadler.com/jacob/), two files that need jacob.jar and jacob.dll can be. And set the Jacob.dll to the PATH. 2. The calling program (Exam_2.java) is as follows: import java.io.file; import com.jacob.com. *; Import com.jacob.activex. *;
public class Exam_2 {public static void main (String [] args) {ActiveXComponent app = new ActiveXComponent ( "Word.Application"); // start word String inFile = "H: // Majix-1_2_2_full // sample // my. DOC "; // Word file to be converted String TPFile =" h: h: //majix-1_2_2_full//sample/My.htm "; // Temporary file String OtFile =" h: // majix-1_2_2_full // Sample / /my.xml";// target file Boolean flag = false; try {app.setproperty ("visible", new variant (false)); // Setting Word invisible Object Docs = app.getProperty ("Documents"). Todispatch (); Object Doc = dispatch.invoke (DOCS, "Open", Dispatch.Method, New Object [] {Infile, New Variant (false), New Variant (TRUE)}, new int} (TODSPATCH) ( ); // Open Word file Dispatch.invoke (DOC, "Saves", Dispatch.Method, new object [] {TPFILE, New Variant (8)}, new int [1]); / / Save as html format to temporary File Variant F = New Variant (false); Dispatch.call (DOC, "Close", F); FLAG = true;} catch (exception e) {E.PrintStackTrace ();} finally {app.invoke ("quit" New variant [] {});} if (flag) {app = new activxcomponent ("Excel. Application "); // Start Excel Try {app.setProperty (" visible ", new variant (false)))); // Sets Excel invisible Object Workbooks = App.getProperty (" Workbooks "). Todispatch (); Object Workbook = Dispatch.invoke (Workbooks, "Open", Dispatch.Method, New Object [] {TPFILE, New Variant (false), new variant (true)}, new int [1]). Todispatch (); // Open temporary file Dispatch.invoke (Workbook, "Saveas", Dispatch.Method, New Object [] {OTFile, New Variant (46)}, new int [1]); // Save to target files in XML format Variant F = New Variant ( False); Dispatch.Call (Workbook, "Close", F);} catch (exception e) {E.PrintStackTrace ();