Word.ApplicationClass word = new Word.ApplicationClass();
   Type wordType = word.GetType(); 
   Word.Documents docs = word.Documents; 
   // 打开文件  
   Type docsType = docs.GetType(); 
   object filename = "c:\\";  
   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 = Server.MapPath("../") + "OfficeFile\\HTML\\"+ "aa.html";
   //下面是Microsoft Word 9 Object Library的写法,如果是10,可能写成: 
   //docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,null, doc, new object[]{saveFileName, Word.WdSaveFormat.wdFormatFilteredHTML});
   ///其它格式:
   ///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});
   // 退出 Word
   wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod,null, word, null);

相关文章:

  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-02-12
  • 2021-07-28
猜你喜欢
  • 2021-05-20
  • 2022-12-23
  • 2021-11-23
  • 2021-08-13
  • 2022-01-04
相关资源
相似解决方案