Convert DOC files to HTML and other formats-
Author: Meng xianhui Source: wonderful world of Meng xianhui
Microsoft Word 9.0 Object Library allows you to convert the format of DOC files on the page. For some methods about word objects, refer to open and save. The following is the conversionCode[C #]:
/// <Summary>
/// Summary of wordtohtml.
/// Add reference: Microsoft Word 9.0 Object Library
/// </Summary>
Word. applicationclass word = new word. applicationclass ();
Type wordtype = word. GetType ();
Word. Documents docs = word. documents;
// Open the file
Type docstype = docs. GetType ();
Object filename = "d :\\ TMP \ aaa.doc ";
Word. Document Doc = (word. Document) docstype. invokemember ("open ",
System. reflection. bindingflags. invokemethod, null, Docs, new object [] {filename, true, true });
// Convert the format and save it
Type doctype = Doc. GetType ();
Object savefilename = "D: \ TMP \ aaa.html ";
// The following is the Microsoft Word 9 Object Library statement. If it is 10, it may be written as follows:
// Doctype. invokemember ("saveas", system. reflection. bindingflags. invokemethod, null,
// Doc, new object [] {savefilename, word. wdsaveformat. wdformatfilteredhtml });
/// Other formats:
/// Wdformathtml
/// Wdformatdocument
/// Wdformatdostext
/// Wdformatdostextlinebreaks
/// Wdformatencodedtext
/// Wdformatrtf
/// Wdformattemplate
/// Wdformattext
/// Wdformattextlinebreaks
/// Wdformatunicodetext
Doctype. invokemember ("saveas", system. reflection. bindingflags. invokemethod, null,
Doc, new object [] {savefilename, word. wdsaveformat. wdformathtml });
// Exit word
Wordtype. invokemember ("quit", system. reflection. bindingflags. invokemethod, null, word, null );