views:

1000

answers:

3

We have a Windows Service which runs on 2003 Server. It opens a source Word document using the Word Interop and then does some stuff with it. It also does likewise with Excel and PowerPoint files.

Recently we've tried moving this service onto a Windows 2008 Server machine and are having real problems with it.

COMException at Microsoft.Office.Interop.Excel.Workbooks.Open COMException at Microsoft.Office.Interop.Word.Documents.Open

I get the above exceptions when the windows service is running on 2008 Server. Looking at the Task Manager, the application does load ok, but then closes again shortly after.

I've read things about Vista and Server 2008 not having a Session0 anymore, and have tried changing the Office DCOM security properties accordingly, including changing the identity of the user running them to Integrated but to no avail.

Does anyone know if this is possible at all? This is a fundamental aspect of our system and so we need to be able to do this.

Thanks

A: 

This also happens on Vista with UAC enabled. You might want to try setting the DCOM identity to be an administrator account and test it again.

I also recently started having this problem on an XP box trying to open workbooks in Excel through interop services, but have not yet found a workaround. I myself would like any other insights the community might be able to throw out there...

Cory Larson
+5  A: 

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 either

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

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

...depending on whether you have 64-bit Windows.

Also, the folder needs write permission for whatever user is "driving" Office.

[Edit: corrected link URL]

Gary McGill

related questions