zoukankan      html  css  js  c++  java
  • 方法“Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)”和非方法“Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close”之间存在二义性。

    方法一:修改创建对象

    Word.Application app = new Word.Application();//可以打开word
    Word.Document doc = null; //需要记录打开的word

    改为:加下划线

    Word._Application app = new Word.Application();//可以打开word
    Word._Document doc = null; //需要记录打开的word

    Word._Application 操作对应的word文件的应用程序。 Word._Document 操作对应的word文件文档。

    oDoc = oWord.Documents.Open(ref oFileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ef oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,ef oMissing, ref oMissing, ref oMissing, ref oMissing);
    //打开FileName对应的word文档,并将文档句柄指定给oDoc,
    后面的ref oMissing一样的参数,因为所有的参数正常情况下都不需要设置,所以都是Missing

     方法二:使用显式转换:

    把doc.Close(ref missing, ref missing, ref missing);

    改为:((Word._Document)doc).Close(ref missing, ref missing, ref missing);

  • 相关阅读:
    看门狗定时器
    fork 和 exec
    openwrt procd分析
    减肥经验总结
    gcc
    laravel5验证码
    laravel5通过auth.attempt事件加入登陆验证码
    双向链表
    mysql5.6源码安装
    laravel4通过控制视图模板路劲来动态切换主题
  • 原文地址:https://www.cnblogs.com/net5x/p/12346337.html
Copyright © 2011-2022 走看看