Automation of MS Word on a 2012 R2 server

First, please do not respond with general advice so as not to automate Word on the server or link to the MS web page "how to automate the word on the server if you really should." I know about it.

I have a process that runs as a Windows service and uses .Net OLE interop to automate Office (mostly just Open and SaveAs). This code worked reliably for 8 years on literally hundreds of servers, using many combinations of versions of Windows and Office, both 32 and 64 bits, so I am glad that the mechanism is reliable. Still...

With Server 2012 R2, it works with PowerPoint and Excel, but does not try to open a Word document:

System.Runtime.InteropServices.COMException (0x800A16A0): The file appears to be corrupted. at Microsoft.Office.Interop.Word.Documents.Open... 

My observations so far, which may or may not be relevant:

  • failure in all documents
  • works fine on windows 8.1
  • the same problem arose both on the customer’s website and in our test environment, so it is unlikely to be purely environmentally friendly.
  • my application uses .Net 3.5
  • the code is associated with Interop 2003 assemblies (obviously, later versions of Office are supported by assembly binding redirection).
  • we tried this with Office 2013 both 32 and 64 bit with the same results, but did not try earlier versions of the office.
  • it does not work, whether the service works as a LocalSystem or as a standard user account
  • if we start the maintenance process in the foreground (i.e. literally double-clicking on the executable file) the problem does not happen

Obviously, I have everything I need to research, but it’s interesting to know if anyone else has seen this particular problem, even if you haven’t solved it. Please note that there are many difficulties and problems with office automation, so if your symptoms are not very similar to mine, you probably do not have the same problem.

+7
ms-word ms-office automation office-interop
source share
6 answers

The same problems are here, but now it's fully resolved.

I have Word 2013 in combination with a Windows 2012 R2 Server running in a maintenance process that does everything I want without having to start an interactive session. I use this to convert documents to PDF files. Inside the windows service, I host the WCF service.

Create folders: (replace System32 with Syswow64 depending on the use of x86 or x64 bit edition)

C: \ Windows \ System32 \ Config \ systemprofile \ AppData \ Local \ Microsoft \ Windows \ INetCache C: \ Windows \ System32 \ Config \ systemprofile \ Desktop

The last and most important step!

 Start - run - dcomcnfg.exe 

Open Properties -> Component Services - DCOM Config - Microsoft Word 97 - 2003 document (note that the version is not mentioned here, but it does not matter. Office 2013 will use this as a DCOM configuration)

Open the Identification tab. Configure the launch as a local administrator account. I did some tests. Word 2013 will work just fine even if the user is not starting an interactive session.

+12
source share

We (My company) are currently facing the same problem, this is more like a copy of your problem. We have completed extensive testing in this area, and now I'm talking to an MS support engineer trying to find a job.

Unfortunately, this is something they don’t want to do, I think they tightened security on Windows Server 2012 so that people don’t.

What we tried that should help you:

  • Server 2012 | Word 2007 | Mistake
  • Server 2012 | Word 2010 | Mistake
  • Server 2012 | Word 2013 | Mistake
  • Client 8.1 | Word 2013 | Mistake

Our problem is that we run the word with a user who is not connected to a user of the local system (i.e., with the type of user that you have when you are logged in). Windows just won't let this happen anymore.

Myself and the MS engineer are working on the “Fooling” windows, thinking that he runs Word as a local service, but the software engineer said that at best it was a long shot, and so far everything that we tried has failed. It does not look good.

Sorry, I don’t have an answer for you, but I suppose they know him well that you are not alone?

+4
source share

I had the same problem with MsOffice 2010 (32 bit) and Windows Server 2012R2 (64 bit). Word, Excel, Powerpoint do not work with localAdmin.

I created the folder C: \ Windows \ System32 \ config \ systemprofile \ AppData \ Local \ Microsoft \ Windows \ INetCac he , as Andy did, and now it works great!

Thanks Andy :)

+1
source share

Thanks for the help and help. After creating the INetCache folder, this worked for me. I did the following to make everything work without an active session (WS2012 R2 / MS Office 2013 64x):

  • Create a local administrator user and log in to configure any printers (print to file), as well as the default word settings.
  • Specify the DCOM configuration identifier for the local administrator created.
  • Create the following file: C: \ Windows \ SysWOW64 \ config \ systemprofile \ AppData \ Local \ Microsoft \ Windows \ INetCac he
0
source share

For some machines you need to run "mmc comexp.msc / 32" to set the DCOM parameter for MS Word. I found that we needed to do this when only the 32-bit version of Word was installed.

0
source share

My service uses MS Word for data merging and combining functions. I am using Word 2016 on Windows Server 2012 R2. My journal says that Word is open, but an error is issued when opening the document.

First, I created the entire proposed folder:

C: \ Windows \ System32 \ Config \ systemprofile \ AppData \ Local \ Microsoft \ Windows \ INetCac he C: \ Windows \ System32 \ Config \ systemprofile \ Desktop C: \ Windows \ SysWOW64 \ Config \ systemprofile \ AppData \ Local \ Microsoft \ Windows \ INetCac he C: \ Windows \ SysWOW64 \ Config \ systemprofile \ Desktop

Only after creating the last directory the problem was resolved.

I did not use the DCOM configuration; my application uses a user account with administrator rights; There was no need to use the LocalSystem account with the "desktop interaction" settings.

Thanks.

0
source share

All Articles