我在页面上运行下面的代码出错:
Object Nothing=System.Reflection.Missing.Value; //取得Word文件保存路径
object filename="d:\\backup\\sn.doc"; //创建一个名为WordApp的组件对象
Word.Application WordApp=new Word.ApplicationClass();
            

Word.Document WordDoc=WordApp.Documents.Open(ref filename,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing);报错误是:接口 Word._Application 的 QueryInterface 失败。我在web.config中也加了<identity impersonate="true" />
Dcomcnfg也运行了,但还是不行

解决方案 »

  1.   

    开始
       运行
       dcomcnfg
       组件服务一项中选择Dcom配置,找到Microsoft word文档,察看属性
       安全选项卡中,启动权限和访问权限,如果为了方便,可以添加Every one的用户
       赋予权限,标识选项卡中选择交互式用户
    另外 在Web.config中 添加模拟用户 <identity impersonate="true"/>
    完毕后重新启动机器检查word是否安装正确
      

  2.   

    在添加组件库时为何没有word object?
    ps: 我已安装word
      

  3.   

    在asp.net中操作word文档可以参考:
    http://www.codeproject.com/aspnet/wordapplication.asp