Interop.Word Documents.Open 为空

2023-12-21

我正在尝试使用 Interop.Word.Application 打开 .docx 文件并转换为 PDF。它作为控制台应用程序工作,但如果我在我的网络应用程序中使用相同的东西,它就不起作用。我尝试查看该文件夹的权限。我给予“网络服务”完全控制权,但我仍然得到未在 word.Documents.Open 设置的对象引用。您能让我知道可能出现什么问题吗?我被这个错误困住了。请告诉我。我很感激任何建议。谢谢。

    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();

如果您仍在寻找答案,我刚刚为我的项目找到了答案。

打开 DCOM 配置设置:

  1. 开始->dcomcnfg.exe
  2. 电脑
  3. 本地计算机
  4. 配置DCOM
  5. 搜索Microsoft Word 97-2003 Documents-> 属性

Tab Identity,改变自Launching User to Interactive User

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Interop.Word Documents.Open 为空 的相关文章

随机推荐