I read an article about converting word to html on the Internet. It feels good to share with you.
ConvertWordToHtml (word. applicationClass word = Type wordtype = word. documents docs = Type docstype = word. document doc = (word. document) docstype. invokeMember (, System. reflection. bindingFlags. invokeMethod, docs, [] {wordfilename, Type doctype = wordsavefilename = strsavefilename = wordsavefilename. substring (, wordsavefilename. length-) + savefilename = (doctype. invokeMember (, System. reflection. bindingFlags. invokeMethod, doc, doctype. invokeMember (, System. reflection. bindingFlags. invokeMethod, doc, wordtype. invokeMember (, System. reflection. bindingFlags. invokeMethod, word ,}Conversion from word to html
Make some preparations before this
1. You must have an office component.
2. Add reference as follows:
Word = Microsoft. Office. Interop. Word;Page reference namespace
3. Add Microsoft. Office. Interop. Word reference to the project.
4. If the code word. applicationClass word = new word. applicationClass (); prompt that the interoperability type cannot be embedded, right-click Microsoft. office. interop. select the attribute of the Word component and change the embedded interoperability type to False to solve the problem.
After that, an html file with the same name will appear in the folder where the word file is located. However, one disadvantage is that the word layout format cannot be saved. Improvement later.