Interop.Word Documents.Open is null

问题描述

程序在Windows Server 2012 R2调用Word组件正常,但是换到Windows Server 2008 R2之后,程序异常。

代码

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

Document doc = word.Documents.Open(filename);

//doc is null

解决

step1

创建文件夹,C:\Windows\System32\config\systemprofile\Desktop

step2

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

参考地址

https://stackoverflow.com/questions/10837437/interop-word-documents-open-is-null

posted @ 2019-08-16 10:12  talentzemin  阅读(404)  评论(0编辑  收藏  举报