Server2008 R2 中拒绝访问 ProgID: "excel.application"及配置Microsoft Excel Application权限解决方案

来源:互联网 发布:js select选中的值 编辑:程序博客网 时间:2024/06/06 08:25

如果按照

http://blog.csdn.net/kongwei521/article/details/43699503

http://blog.csdn.net/kongwei521/article/details/43698667

两个链接里面都无法解决的话

采用终极办法

C:\Windows\SysWOW64\config\systemprofile\Desktop 64位系统

C:\Windows\System32\config\systemprofile\Desktop 32位系统

目录设置为Everyone和NetWorkSerices 等等 权限即可。

如果没有Desktop 这个文件夹 则自行创建后赋予权限即可。

相关可参考

http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91 

http://yeppfly.blog.51cto.com/405635/964304

Working config: Microsoft Excel Enterprise 2007 + Windows Server 2008 x64 edition + .NET 4.0 web application

 

Server Error in '/excel' Application.


Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

This error is basically saying that the IIS / ASP.NET framework does not have permission under its current user to run/access COM Objects.

Following the instructions here http://www.computerperformance.co.uk/Logon/code/code_80070005.htm Led me to a solution. Using DCOMCNFG you can set COM permissions. However, instead of just setting COM permissions on the 'Microsoft Excel Application', I needed to set permissions for the entire computer. The linked article has you setting permissions for 'Everyone' but that's not necessary. You only need to set permissions for NETWORK SERVICE user.

Originally, I had followed the steps located here: http://blog.crowe.co.nz/archive/2006/03/02/589.aspx ... those steps have you set permissions to NETWORK SERVICE but only on the Excel Application. For some reason, that wasn't enough on my environment, I needed to set it on the entire 'My Computer' and not the individual app.

OK, so I set up permissions, but then I was getting a totally different error, one that didn't jive at all:

 

“Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space.

• To make more memory available, close workbooks or programs you no longer need.

• To free disk space, delete files you no longer need from the disk you are saving to.”

 

This is of course false. My machine had plenty of space. So what gives?

This is the hardest part to grok, IMHO. This error will NOT occur in Windows Server 2008 32 bit edition (x86). Why not? Because the Folder Structure is different for a user in x64 edition. Excel, when opened, actually tries to create some temporary files or other data when it loads. If it does not have the ability to write to the disk (either because the disk is actually full, or in our case, because that folder is not something we can write to due to security setup), then the disk error is the default message shuttled back to the user. Here are the write locations

C:\Windows\SysWOW64\config\systemprofile\Desktop (x64, does not exist by default)

C:\Windows\System32\config\systemprofile\Desktop (x86, exists by default and is writeable)

http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91

has more on this issue. Basically, to get this to work, take two steps: Create C:\Windows\SysWOW64\config\systemprofile\Desktop and give C:\Windows\SysWOW64\config\systemprofile folder write access to 'Everyone'. This will allow excel to proceed past this error and hopefully start automating files for you.

Finally, I was getting one last error after doing this step:

 

Service cannot be started. System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file 'c:\temp\test.xls'. There are several possible reasons:

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.

 

This is because the folder I was trying to write to was not allowed full-control rights by NETWORK SERVICE. If you app writes excel files to a directory, that directory must be full-control permissioned to NETWORK SERVICE.

ONE OTHER THING: If you are running an OFFICE TRIAL VERSION and you have not entered a license key, your app might hang and never load anything. This is because the COM Object actually spawns a modal dialog for a license key and your code will wait there for a user who will never come to add a license key. So, be sure if you're automating excel that you ONLY using a registered version and not a 30 day trial or unlicensed version.



0 0