- C# code
public void wordchangetohtml(string sourcepath, string htmlpath) { try { Word.ApplicationClass word = new Word.ApplicationClass(); Type wordType = word.GetType(); Word.Documents docs = word.Documents; // 打开文件 Type docsType = docs.GetType(); object fileName = sourcepath; Word.Document doc = (Word.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { fileName, true, true }); // 转换格式,另存为 Type docType = doc.GetType(); object saveFileName = htmlpath; ///wdFormatUnicodeText docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, Word.WdSaveFormat.wdFormatHTML }); // 退出 Word wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null); } catch (Exception EX) { throw EX; } }
<identity impersonate="true" userName="administrator" password="1"/>这个我已经设置了!
------解决方案--------------------------------------------------------
你这些相关的Wrod类所依赖的底层组件在服务器上是否有安装
就好像你本地装了word能打开word文件,但服务器没有安装word,你把word文件传到服务器,想在服务器端打开,你觉得能打开吗?