Home » Development » Solved: .NET Excel Interops issue: “Microsoft Office Excel cannot access the file abc.xlsx”

Solved: .NET Excel Interops issue: “Microsoft Office Excel cannot access the file abc.xlsx”

I was trying to open an Excel file programmatically in my .NET web application. I used the code in one my previous posts. Unfortunately, I found myself struggling with this hair-pulling issue:

Microsoft Office Excel cannot access the file ‘c:\file.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.

Solution

As it’s stated here, follow these 2 easy steps. Then you can go back to your normal life!

  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. Set full control permissions on Desktop directory above (for example in Win7 > IIS 7 > DefaultAppPool: set permissions for user IIS AppPool\DefaultAppPool)

 

Ned Sahin

Blogger for 20 years. Former Microsoft Engineer. Author of six books. I love creating helpful content and sharing with the world. Reach me out for any questions or feedback.

9 thoughts on “Solved: .NET Excel Interops issue: “Microsoft Office Excel cannot access the file abc.xlsx””

Leave a Comment