通过Windows 2008 Server上的Windows Service自动化Office [英] Automating Office via Windows Service on Server 2008

查看:172
本文介绍了通过Windows 2008 Server上的Windows Service自动化Office的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Windows Server,可以在2003 Server上运行.它使用Word Interop打开源Word文档,然后执行一些操作.对于Excel和PowerPoint文件也同样如此.

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.

最近,我们已尝试将该服务移至Windows 2008 Server计算机上,并且确实遇到了问题.

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

COMException Microsoft.Office.Interop.Word.Documents.Open上的COMException

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

当Windows服务在2008 Server上运行时,出现上述异常.查看任务管理器,该应用程序确实加载正常,但不久后再次关闭.

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.

我已经阅读了有关Vista和Server 2008不再具有Session0的知识,并尝试相应地更改Office DCOM安全属性,包括将运行它们的用户的身份更改为集成",但无济于事.

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.

谢谢

推荐答案

即使在Windows Server 2003下工作正常,我也无法从Windows Server 2008下的Windows Service中自动执行Office的问题.电话,所以可能是同样的问题.

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.

我尝试遵循H Ogawa在此MSDN线程,它似乎可以正常工作.这很奇怪,但是小川先生发现它很赞.

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.

"Ogawa Hack"的摘要:为系统配置文件创建一个桌面文件夹,如下:

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

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

(如果在64位计算机上运行),则创建另一个 ,如下所示:

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.

这篇关于通过Windows 2008 Server上的Windows Service自动化Office的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆