Excel 2007 automation on top of a Windows Server 2008 x64

天大地大妈咪最大 提交于 2019-11-27 06:45:31

The solution is really simple. The msdn forum thread can be found here

To make a long story short I'm posting the solution here, credit goes to H Ogawa

This solution is ...

・Windows 2008 Server x64

Please make this folder.

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

・Windows 2008 Server x86

Please make this folder.

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

...instead of dcomcnfg.exe.

This operation took away office automation problems in my system.

A Desktop folder seems to be necessary in the systemprofile folder to open file by Excel.

It disappears from Windows2008, Windows2003 had the folder, and I think it cause this error.

Also like stated in the source, you need to set the correct rights for the Desktop folder. This worked for me on Windows 2008-64bits and Office 2010 32bits.

  1. Create directory "C:\Windows\SysWOW64\config\systemprofile\Desktop " (for 64 bit Windows) or "C:\Windows\System32\config\systemprofile\Desktop " (for 32 bit Windows)

  2. Assign user "Network Services (Service Réseau)" the following rights for the created folder:

Read & Execute, List folder contents, Read

John.

I've quite often found that calling Quit() isn't enough to release the resources. Try adding: -

System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);

between the Quit() statement and setting it to null.

There are many more errors than the one mentioned that you'll need to work through in order to get Excel working on Windows Server 2007 64-bit. See the steps I worked out after working on this for two full days!

If you are using Apache, you might also need to follow these steps to get MS Word working properly (along with everything outlined in other answers):

Below is a screenshot showing the two dialogs you'll need to bring up:

For Apache:

Services->Apache->Right Click (Properties)->Log On Tab

MS Word:

Launch dcomcnfg.exe->Console Root->Component Services->Computers->My Computer->DCOM Config->Find Microsoft Application->Right Click(Properties)->Identity Tab

**if you can't find the MS Word, make sure you are launching the correct DCOM Config (64 bit vs 32 bit) depending on what version of Office you have installed.

There are two options here, you can set Apache to use Local System Account and check the checkbox to ALLOW desktop interaction. If you do this then you need to set the Identity for MS Word to Interactive User.

Otherwise, you need to set both to the same user (Ideally the user that is logged in) like shown in the picture.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!