Microsoft.Office.Interop Issue – Microsoft Excel cannot access the file 'D:\xxx\xx\xxx.xlsx'. There are several possible reasons:

QuestionsCategory: C#Microsoft.Office.Interop Issue – Microsoft Excel cannot access the file 'D:\xxx\xx\xxx.xlsx'. There are several possible reasons:
Manoj KadamManoj Kadam asked 1 year ago

Getting error when application is trying to open excel programatically using interop
Microsoft Excel cannot access the file ‘D:\xxx\xx\xxx.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. at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad).
 
Error code -2146827284

1 Answers
Mahesh DeshmaneMahesh Staff answered 1 year ago

 

Make sure the file is exist in the location mentioned in the error message also make sure the file is not in use by any other application/service, while your application is trying to open the same file for edit. To resolve the above issue, perform below steps

Step 1:

  • Make sure the file which you are trying to open is not a read-only fileexcel read-only properties Also, make sure the folder which contains the file is not read-only and has all necessary rights
    folder-read-only-properties

folder access

  • Hopefull  step1 will resolve the issue but if the issue still persists then perform step 2

Step 2:

  • Open the Component Services
    • 32-bit machine “mmc comexp.msc /32”
    • 64-bit machine “dcomcnfg”

open component service

  • Navigate to Console Root -> Component Services -> Computers -> My Computer -> DCOM Config -> Select Microsoft Excel Application -> Right Click and go to properties. -> go to the security tab and give full control to the respective users

component service security tab

  • Then go to Identity tab ->  select “The interactive user” option.

component service identity tab

  • Click on Apply and Ok button again check the issue if the issue still persists then perform step 3

Step 3:

  • Create a folder
    • For 64-bit machine Create directory “C:\Windows\SysWOW64\config\systemprofile\Desktop”
    • for 32-bit machine  Create directory “C:\Windows\System32\config\systemprofile\Desktop “
  • Set Full control permissions for new created folder Desktop.

Hope this will help to resolve the issue. moreover, you can read more details below the issue Interop Excel Issue.