Excel automation on windows server throws "Microsoft Excel cannot access the file xxx"

Error :

 Microsoft Excel cannot access the file '...Test.xlsx'. 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


Scenario #1 :

My excel automation application was a Windows Service application. When I run the windows service to perform Excel automation, I was getting 

Microsoft Excel cannot access the file '...Test.xlsx' error.

I tried to change the Log On account of my service from Local System to current login user, administrator account, but nothing works.


Scenario #2 :

I was using SOAP & RESTful web services, which was having the services to perform Excel automation, and which are configured in IIS manager(Internet Information Services).

I was getting the same error here in this scenario also.


Solution :

After so many options, I found the solution. It doesn't require changing registry values and everything works properly.

This solution is,

Create the below directories,

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

(For x64)

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

(For x86)

Give full permission to the current user for the Desktop directory.

Note :

#1 If you are running Windows service under Local System account, and if it didn't work, then try to run the service with the current user account.

#2 If you are running Web application / Web services then set permissions for a user in IIS AppPool





No comments:

Post a Comment

Pages