好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

使用wordapi打开word文档.docx

2页
  • 卖家[上传人]:xiao****1972
  • 文档编号:84917081
  • 上传时间:2019-03-05
  • 文档格式:DOCX
  • 文档大小:29.76KB
  • / 2 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 杭州java软件培训 使用Word API(非Openxml)打开Word文档简单示例(必须安装Word)1. 首先需要引入参照Microsoft.Office.Interop.Word2. 代码示例 1 public void OpenWord() 2 { 3 // Word应用对象 4 Word.Application wdApp = null; 5 // Word文档对象 6 Word.Document wdDoc = null; 7 8 // Word路径 9 object oWdPath = "XXXXXXXXXXXXXX";10 // Word设定:缺损项11 object oMissing = System.Reflection.Missing.Value;12 // Word设定:不保存13 object doNotSaveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;14 15 try16 {17 // 新建Word应用18 wdApp = new Word.Application();19 // 设置Word应用为可见20 wdApp.Visible = true;21 // 打开Word文档22 wdDoc = wdApp.Documents.Open(ref oWdPath,23 ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,24 ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,25 ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);26 }27 finally28 {29 #pragma warning disable30 // 关闭Word文档31 if (wdDoc != null) { wdDoc.Close(); wdDoc = null; }32 // 关闭Word应用33 if (wdApp != null) { wdApp.Quit(ref doNotSaveChanges, ref oMissing, ref oMissing); wdApp = null; }34 #pragma warning disable35 GC.Collect();36 }37 }杭州网络营销培训 。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.