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);

  • 相关阅读:
    R 画structure图
    perl ExtUtils::Manifest
    解决libstdc++.so.5问题
    R ggplot2 线性回归
    perl 计算方差中值平均数 Statistics::Descriptive;
    专题(十一)scp
    tcpdump的使用
    专题 (四) sed
    python 学习笔记(二)之 字符串操作
    redis 学习笔记之(二)主备高可用(热备)
  • 原文地址:https://www.cnblogs.com/net5x/p/12346337.html
Copyright © 2011-2022 走看看