Microsoft Excel无法访问文件“...”。 Windows Server 2008 R2与Microsoft Office 2010有几个可能的原因 [英] Microsoft Excel cannot access the file "...". There are several possible reasons Windows Server 2008 R2 with Microsoft Office 2010
问题描述
我尝试通过应用程序X(而不是Windows任务计划程序)安排此脚本(C#)这个应用程序将始终使用服务帐户在服务器上运行服务)。如果我在同一用户的命令提示符下运行C#脚本,它将运行。在使用完全相同的用户的应用程序X下,启动C#脚本,它无法打开Excel应用程序(没有足够的权限?)。
此脚本调用:
app.Workbooks.Open(ExcelFileName,0,false,Type.missing ....),但它给出以下错误:
Microsoft Excel无法访问文件...。有几个可能的原因:
- 文件名或路径不存在。
- 文件是被另一个程序使用。
- 您尝试保存的工作簿与当前打开的工作簿名称相同。
尝试所有在线查找的方法无效。
- 创建目录C:\Windows\SysWOW64 \config \systemprofile\Desktop(对于64位Windows)或C:\Windows\System32\config\systemprofile\Desktop(对于32位Windows)。然后在上面的桌面目录中设置完全控制权限(例如,对于用户IIS AppPool\DefaultAppPool,例如Win7& IIS 7& DefaultAppPool设置权限)
- 将DCOM配置更改为将Microsoft Excel应用程序包含在本地/远程启动和访问中的用户
- 启用Excel中的所有宏并设置信任中心。
- 添加用户对所有包含Excel文件的文件夹进行完全控制。
- 在DCOM配置,Microsoft Excel应用程序下,如果我修改Identity标签以检查此用户并输入用户名/密码允许Excel始终在该用户下运行。然后应用程序运行完美。但是,其他用户无法自行运行excel应用程序,具有以下错误:无法使用对象链接和嵌入。如果我查看使用启动用户,则无法启动Excel。在任何地方检查的日志或事件中没有错误。
然而,仍然是一样的错误。我认为这是许可,但我不知道该在哪里工作。
现在,通常,当我运行这个excel报告时,我可以双击在文件中,它会自动运行,将新参数保存到当前文件中,并生成一个新的excel文件(附带文件名的日期)。
感谢您的帮助!
我发现问题是服务器中的安全层!
在C:\Windows\System32\config\systemprofile中创建Desktop文件夹,并提供服务帐户访问桌面文件夹的权限是不够的。
我修改了C:\Windows\System32\config(或C:\windows\SysWOW64\config)文件夹以允许服务的权限帐户在安全选项卡。
然后,我还必须为子文件夹C:\Windows\System32\config\systemprofile(或C:\windows\SysWOW64\config\systemprofile)。
这个工作!
I have a problem with starting the Excel Application under a particular user.
I try to schedule this script (C#) through an application X (not Windows Task Scheduler. And this application will always use a service account to run services on the server). If I run the C# script in command prompt under the same user, it runs. Under the application X, which uses the exact same user, to initiate the C# script, it fails to open the Excel application (not sufficient permission?).
This script calls: app.Workbooks.Open(ExcelFileName,0,false,Type.missing....), yet it gives the following error:
Microsoft Excel cannot access the file "...". 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.
I tried all the methods that I found online to no avail.
- Create directory "C:\Windows\SysWOW64\config\systemprofile\Desktop" (for 64 bit Windows) or "C:\Windows\System32\config\systemprofile\Desktop" (for 32 bit Windows). Then Set full control permissions on Desktop directory above (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user "IIS AppPool\DefaultAppPool")
- Changed the DCOM config for the Microsoft Excel application to include this user for Local/Remote Launch and Access
- Enabled all macros in Excel and set the Trust Center.
- Add the user to have full control on all folders that contain the Excel file.
- Under DCOM config, Microsoft Excel Application, if I modify the Identity tab to check on "This User" and enter the username/password to let Excel always run under that user. Then the application runs perfectly. However, other users can't run the excel application on their own with the following error: "Cannot use object linking and embedding". If I check "Use the launching user", then Excel can't be launched. No errors in the logs or events anywhere to check.
Yet, still the same error. I think it's permission but I am not sure where and what to do for this to work.
Now, normally, when I run this excel report, I can double-click on the file and it'd automatically run, save the new parameters into the current file and generate a new excel file (with date attached to the file name). That means there is a change (save) to the original file.
I appreciate all your help!
I found the problem is the layer of security in the server!
Creating the Desktop folder inside the C:\Windows\System32\config\systemprofile and giving the service account permission to access the desktop folder is not enough.
I modified the C:\Windows\System32\config (or C:\windows\SysWOW64\config) folder to allow permission to the service account in security tab.
Then I also had to set up the same permission for the sub folder C:\Windows\System32\config\systemprofile (or C:\windows\SysWOW64\config\systemprofile) for the service account.
This works!
这篇关于Microsoft Excel无法访问文件“...”。 Windows Server 2008 R2与Microsoft Office 2010有几个可能的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!