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:WindowsSystem32configsystemprofileDesktop

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

原文地址:https://www.cnblogs.com/talentzemin/p/11362214.html