Interop.Word Documents.Open为null [英] Interop.Word Documents.Open is 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配置设置:
- 开始 - >
DCOMCNFG.EXE
- 电脑
- 本地计算机
- 配置DCOM
- 搜索
的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:
- Start ->
dcomcnfg.exe
- Computer
- Local Computer
- Config DCOM
- Search for
Microsoft Word 97-2003 Documents
-> Properties
Tab Identity
, change from Launching User
to Interactive User
这篇关于Interop.Word Documents.Open为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!