title: Automating MS Word in Server 2012 R2
body: <p>Firstly, please don't reply with the generic advice not to automate Word on a server or a link to the MS web page on "how to automate word on a server if you really must". I am aware of this.</p>
  
  <p>I have a process which runs as a Windows service and uses .Net OLE interop to automate Office (mostly just Open and SaveAs). This code has worked reliably for 8 years on literally hundreds of servers using many combinations of Windows and Office versions, both 32 and 64 bit, so I am happy that the mechanism is reliable. So far...</p>
  
  <p>With Server 2012 R2, it works with PowerPoint and Excel but fails trying to open a word document:</p>
  
  <pre><code>System.Runtime.InteropServices.COMException (0x800A16A0): 
    The file appears to be corrupted.
     at Microsoft.Office.Interop.Word.Documents.Open...
  </code></pre>
  
  <p>My observations so far which may or may not be relevant:</p>
  
  <ul>
  <li>fails on all documents</li>
  <li>works fine in Windows 8.1</li>
  <li>the same problem has happened both on a customer site and in our test environment, so is unlikely to be purely environmental</li>
  <li>my application is using .Net 3.5</li>
  <li>the code is linked against the 2003 Interop assemblies (obviously later office versions are supported by assembly binding redirection)</li>
  <li>we have tried it with office 2013 both 32 and 64 bit with the same results, but not tried earlier versions of office</li>
  <li>it fails whether the service is running as LocalSystem or as a standard user account</li>
  <li>if we run the service process in the foreground (i.e. literally double-clicking on the executable) the problem does not happen</li>
  </ul>
  
  <p>Obviously I still have things to investigate but interested to hear if anyone else has seen this specific problem even if you haven't solved it. Please note there are many difficulties and problems with office automation so unless your symptoms are very similar to mine, you probably don't have the same problem.</p>