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

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

问题描述

我正在尝试使用 Interop.Word.Application 打开 .docx 文件并转换为 PDF.它作为控制台应用程序工作,但如果我在我的 Web 应用程序中使用它,它就不起作用.我试图查看文件夹的权限.我完全控制了网络服务",但仍然没有在 word.Documents.Open 中设置对象引用.你能告诉我可能是什么问题吗?我被这个错误困住了.请告诉我.我很感激任何建议.谢谢.

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	est.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.

打开 DCOM 配置设置:

Open DCOM Config Settings:

  1. 开始 -> dcomcnfg.exe
  2. 电脑
  3. 本地计算机
  4. 配置 DCOM
  5. 搜索 Microsoft Word 97-2003 文档 -> 属性
  1. Start -> dcomcnfg.exe
  2. Computer
  3. Local Computer
  4. Config DCOM
  5. Search for Microsoft Word 97-2003 Documents -> Properties

Tab Identity,从Launching User改为Interactive User

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

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