Interop.Word Documents.Open为null [英] Interop.Word Documents.Open is null

查看:1301
本文介绍了Interop.Word Documents.Open为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打开.docx文件,并使用Interop.Word.Application转换为PDF。它可以作为控制台应用程序,但如果我用同样的在我的Web应用程序中这是行不通的。我试图查看该文件夹的权限。我给'网络服务'完全控制,但我还是得到对象引用未设置到word.Documents.Open。能否请你让我知道可能是什么问题呢?我坚持这个错误。请告诉我。我AP preciate任何建议。谢谢你。

  Microsoft.Office.Interop.Word.Application字=新Microsoft.Office.Interop.Word.Application();    反对oMissing = System.Reflection.Missing.Value;    word.Visible = FALSE;
    word.ScreenUpdating = FALSE;
    字符串文件名= @C:\\输出\\ test.docx);
    文档的DOC = word.Documents.Open(文件名,参考oMissing,
            REF oMissing,裁判oMissing,裁判oMissing,裁判oMissing,REF oMissing,
            REF oMissing,裁判oMissing,裁判oMissing,裁判oMissing,REF oMissing,
            REF oMissing,裁判oMissing,裁判oMissing,裁判oMissing);
        doc.Activate();


解决方案

如果你还在寻找答案我发现它刚才为我的项目。

打开DCOM配置设置:


  1. 开始 - > DCOMCNFG.EXE

  2. 电脑

  3. 本地计算机

  4. 配置DCOM

  5. 搜索的Microsoft Word 97-2003文档 - >属性

标签身份,从变化启动用户交互式用户

I am trying to open .docx file and convert to PDF using Interop.Word.Application. It works as console application but If I use the same in my web application it doesn't work. I tried to see the permissions on the folder. I gave 'Network Service' with full control, but still I get object reference not set at word.Documents.Open. Could you please let me know what could be the problem? I am stuck with this error. Please let me know. I appreciate any suggestions. Thank you.

    Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();

    object oMissing = System.Reflection.Missing.Value;

    word.Visible = false;
    word.ScreenUpdating = false;
    string fileName = @"c:\OUTPUT\test.docx");
    Document doc = word.Documents.Open(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, ref oMissing);
        doc.Activate();

解决方案

If you are still looking for the answer I have found it just a moment ago for my project.

Open DCOM Config Settings:

  1. Start -> dcomcnfg.exe
  2. Computer
  3. Local Computer
  4. Config DCOM
  5. Search for Microsoft Word 97-2003 Documents -> Properties

Tab Identity, change from Launching User to Interactive User

这篇关于Interop.Word Documents.Open为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆