Automating Office via Windows Service on Server 2008

I’ve had problems automating Office from a Windows Service under Windows Server 2008, even though that works fine under Windows Server 2003. The problem also occurs at the Open call, so it may be the same problem.

I tried following the advice given by H Ogawa in this MSDN thread, and it seemed to work. It’s bizarre, but kudos to Mr. Ogawa for discovering it.

Summary of the ‘Ogawa Hack’: create a desktop folder for the system profile, as:

 C:\Windows\System32\config\systemprofile\Desktop

and, if running on a 64-bit machine, create another one, as:

 C:\Windows\SysWOW64\config\systemprofile\Desktop

Also, the folder(s) need write permission for whatever user is “driving” Office.


[Edit: corrected link URL]

[Edit 2: clarified that on 64-bit Windows, you need both folders, not just the WOW64 one]

Leave a Comment