求救:关于操作Word文件的问题

cbw99 2002-08-15 05:42:29
在Winform里我用C#操作Word文件,用WebBrowser显示Word文件,但是在使用WebBrowser的“ExecWB”方法保存Word文件后,再用Word对象打开该文件时就会报如下错误:“未处理的“System.Runtime.InteropServices.COMException”类型的异常”,我操作Word的代码如下:
string sFileName="c:\temp.doc";
object objFileName = (object)sFileName;

Word.Application Word_App = null;
Word.Document Word_doc=null;
Word.Shape oShape=null;
Word_App = new Word.Application();
Word_doc=new Word.Document();
Word.Documents Docs = Word_App.Documents;
Word_App.Visible=false;
Word._Document my_Doc= (Word._Document) Word_doc;

Word_doc=Docs.Open(ref objFileName,ref refmissing,ref refmissing,ref refmissing,ref refmissing,ref refmissing,ref refmissing,ref refmissing,ref refmissing,ref refmissing,ref refmissing,ref refmissing);
错误报在最后一句话的“Open”方法上。
请问各位大侠这是怎么回事啊?
...全文
22 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2002-09-02
  • 打赏
  • 举报
回复
Object oMissing = System.Reflection.Missing.Value;
Word.Application Word_App=new Word.Application();
Word.Document Word_doc=new Word.Document();
Word.Documents Docs = Word_App.Documents;
Word._Document my_Doc= (Word._Document) Word_doc;
object FileName=Server.MapPath(".")+"/aa.doc";
Word_doc=Docs.Open(ref FileName,ref oMissing, ref oMissing, ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing);
Word_App.Visible =true;
pursuer 2002-09-02
  • 打赏
  • 举报
回复
建议使用RichTextBox控件来显示WORD文档
cbw99 2002-08-16
  • 打赏
  • 举报
回复
高手帮帮忙啊
cbw99 2002-08-16
  • 打赏
  • 举报
回复
有没有人知道阿

110,533

社区成员

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

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

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