c#操作word,Document.Close方法和Application.Quit方法疑问

learn2003 2007-12-26 01:59:32
方法“Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)”和非方法“Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close”之间存在二义性。将使用方法组。

方法“Microsoft.Office.Interop.Word._Application.Quit(ref object, ref object, ref object)”和非方法“Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit"之间存在二义性。将使用方法组。

为什么出出现这个情况?是什么意思?
...全文
2749 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhupeike 2012-09-24
  • 打赏
  • 举报
回复
感谢,我的问题也解决了
CroftonWeed 2011-07-13
  • 打赏
  • 举报
回复
谢谢了 解决了
fcsd1017 2011-04-01
  • 打赏
  • 举报
回复
谢谢,答案是正确的,问题解决了
yu_712 2010-09-14
  • 打赏
  • 举报
回复
我也有类似的问题:
Word.Application App = new Word.Application();

App.Quit(ref missing, ref missing, ref missing);//报错和上面一样,
App = null;
为什么会这样?
volkswageos 2010-03-27
  • 打赏
  • 举报
回复
[Quote=引用楼主 learn2003 的回复:]
方法“Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)”和非方法“Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close”之间存在二义性。将使用方法组。

方法“Microsoft.Office.Interop.Word.……
[/Quote]

同时也在关注不适用组件的方法,excel的不适用组件的我已经有了,还没有word的,希望互相帮助
volkswageos 2010-03-27
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 liruixu 的回复:]
Word._Document doc = wordApp.Documents.Open(ref fileobj, ref nullobj, ref nullobj,
在document前面加个_就可以了


上面这个答案对头,谢谢。

烟台-随缘素位
[/Quote]

这个方法好,没有警告了,但是这个是为什么呢?
liruixu 2010-01-30
  • 打赏
  • 举报
回复
Word._Document doc = wordApp.Documents.Open(ref fileobj, ref nullobj, ref nullobj,
在document前面加个_就可以了


上面这个答案对头,谢谢。

烟台-随缘素位
ruanyang12345 2009-01-19
  • 打赏
  • 举报
回复
Word._Document doc = wordApp.Documents.Open(ref fileobj, ref nullobj, ref nullobj,
在document前面加个_就可以了
SnowWolf0825 2008-08-28
  • 打赏
  • 举报
回复
去掉多于的组件引用,就可以了
我解决了这个问题!
shilei831115 2008-04-22
  • 打赏
  • 举报
回复
涉及到方法间存在二义性的问题时,把绝对的命名空间名都引用上应该OK……

貌似一般都是静态方法会报这样的错误……
xxcw 2008-04-22
  • 打赏
  • 举报
回复
我也有这样的问题
ericzhangbo1982111 2008-04-16
  • 打赏
  • 举报
回复
//Word.ApplicationClass WordApp = new Word.ApplicationClass();

//// give any file name of your choice.
//object fileName = "D:\\aa.doc";
//object readOnly = false;
//object isVisible = false;

//// the way to handle parameters you don't care about in .NET
//object missing = System.Reflection.Missing.Value;
//WordApp.Visible = false;
//// Make word visible, so you can see what's happening
////WordApp.Visible = true;
//// Open the document that was chosen by the dialog
//Word.Document aDoc = WordApp.Documents.Open(ref fileName,
// ref missing, ref readOnly, ref missing,
// ref missing, ref missing, ref missing,
// ref missing, ref missing, ref missing,
// ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);

//Word.WdStatistic stat = Word.WdStatistic.wdStatisticPages;
//int num = aDoc.ComputeStatistics(stat, ref missing);
//System.Console.WriteLine("The number of pages in doc is {0}",
// num);

//foreach (Word.Range r in aDoc.Words)
//{
// Debug.WriteLine("value:" + r.Text);
//}
//System.Console.ReadLine();
//object o = false;
//aDoc.Close(ref o, ref missing, ref missing);
//WordApp.Quit(ref o, ref missing, ref missing);

出现这样的错误是代码的问题....
ZJJ3893 2008-04-15
  • 打赏
  • 举报
回复
我也遇到这样的问题啊!但不是出错,只是警告!但程序运行到该处时报告错“此方法或属性无效 因为 此文档在另一应用程序中 ”,不知什么原因!急啊!大哥们帮忙啊!
龙宜坡 2007-12-27
  • 打赏
  • 举报
回复
code?
lemon_lyk 2007-12-27
  • 打赏
  • 举报
回复
我也遇到了但不知为什么
顶一下
bestshl 2007-12-26
  • 打赏
  • 举报
回复
贴出你的代码
bess19820628 2007-12-26
  • 打赏
  • 举报
回复
ding
zmaini1420 2007-12-26
  • 打赏
  • 举报
回复
友情帮顶一下!

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧