The headache for this problem was not allowed to have a headache for this issue. Later, the information was finally solved; the program was now released so that the procedure is now reference. / / -------------------------------------------------------------------------------------------- ------------------------------ // Copyright (c) Wave Group Commercial System Co., Ltd. All rights // file name : Wordtohtml file version: 1.00.00 // Author: Guo Joji Author E-mail: guozhu@langchao.com Complete Date: 2004-10-20 // File Description: // Other Description: // Class List: // WordTohtml: Transform all DOC files below the specified directory into HTML and store it in the same directory // Modify History: // # Version Modification Date Author modified content // --------------- -------------------------------------------------- --------- // 1 1.00.01 2004-10-14 Author name modified content description // ----------------------- -------------------------------------------------- --- // --------------------------------------------- --------------------------------- Import com.jacob.Activex. * Import java.io. *;
// Get all DOC file names under the specified directory Name Public Class Wordtohtml {// ------------------------------- -------------------------------------------- // method prototype: Change (String Paths) // Function Description: Transform all DOC files below the specified directory into HTML and store it in the same directory // input parameters: String // Output parameters: None // Return Value: No // Other instructions: Recourse // ----------------------------------------------- ------------------------------- Public Static Void Change (String Paths, String SavePaths) {file D = new file (Paths ); // obtain list of all files and directories under the current folder File Lists [] = D.ListFiles (); string pathss = new string ("");
/ / Retrieve FOR (INT I = 0; I Boolean Flag = false; "Visible", new variant (false)); // Setting Word Not visible 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 [1]). Todispatch (); // Open Word file dispatch.invoke (DOC, "Saveas", Dispatch.Method, New Object [] {TPFILE, New Variant (8)}, new int [1]); // Save to temporary file Variant f = new variant (false) as HTML format; Dispatch.call (DOC, "Close", F); FLAG = true;} catch (exception e) {E.PrintStackTrace ();} finally {app.invoke ("quit", new variant [] {};} System.out.println ("Transformation is completed!");}}}}}}}}}}}} Else {pathss = paths; // Go to the next directory Pathss = Pathss Lists [i] .GetName () "//"; // Removal All directory Change (pathss, savepaths);}}} // ------------------------------------ ------------------------------------------ // Method prototype: main (String [] args ) // function description: main file // input parameter: None // Output parameter: None // Return value: None // Other instructions: NOTE -------------------------------------------------- ------------ Public static void main (string [] args) {string paths = new string ("D: //work//2004.10.8//test system // TEST01 / / WORD // "); string savepaths = new string (" D: //work//2004.10.8/test system // test01 // html // "); Change (Paths, SavePaths); }} Where import's JAR package is an open source, online search. Dispatch.invoke (Doc, "Saveas", Dispatch.Method, New Object [] {TPFILE, New Variant (8)}, new int [1]); Modify Variant (8)}, you can transform Word For various types.