Search code examples
c#asp.netiisms-wordoffice-interop

Word automation server-side not working


PREFACE: Yes, I know that Microsoft does not recommend this. However, this server is internal-facing in a heavily restricted VLAN.

The goal is to automatically generate specific types of reports that I could not get formatted properly using the Office XML. One of the reasons Microsoft does not recommend this is that the user account must be interactive (i.e. NOT ASPNET). So if I set the application pool identity to run as a user, I no longer get COM errors, but Word still will not open using the following test code:

//Just checking if Word can be accessed
Word.Application app = new Word.Application();
app.Visible = true;

I do not get any errors, but Word will not open. This works when I use it on my development machine debugging with Visual Studio, but on my test machine when deployed I get nothing. Any tips would be greatly appreciated.


Solution

  • Even if the application pool is running under user account, it does not mean that it is interactive and can access your desktop. You can check the list of running processes to find out if Word is there.