none
Microsoft Excel cannot access the file “…”. There are several possible reasons. Windows Server 2008 R2 with Microsoft Office 2010 RRS feed

  • Question

  • I have a problem with starting the Excel Application under a particular user (service account).

    I try to schedule this C# script 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 application.Workbooks.Open(<ExcelFileName>,0,false,Type.missing....). At this line

    of code, 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 as follow:

    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. Changed the DCOM config for the Microsoft Excel application to include this user for Local/Remote Launch and Access.
    3. Enabled all macros in Excel application and set the Trust Center.
    4. Add the user to have full control on all folders that contain the Excel file.
    5. 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.

    Environment: Windows Server 2008 R2 and running Microsoft Excel 2010.

    I appreciate all your help!






    • Edited by tntng Tuesday, February 24, 2015 4:43 PM
    Tuesday, February 24, 2015 12:06 AM

All replies

  • I am wondering if this has anything to do with having the user log into Excel.

    In point #5 above: 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.

    Because running with the launching user proposes an user to run the Excel application. However, I do not think there is any where that we can pass in the password for this user to Excel. However, this Excel has all the permissions to Excel application as well as the folders that have the Excel files.

    Please help!

    Thank you!

    Tuesday, February 24, 2015 4:34 PM
  • 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!
    • Proposed as answer by Serkan Arslan Thursday, April 5, 2018 9:28 AM
    • Unproposed as answer by Serkan Arslan Wednesday, June 27, 2018 11:00 AM
    • Proposed as answer by Serkan Arslan Wednesday, June 27, 2018 11:00 AM
    Friday, February 27, 2015 4:03 PM
  • Hi 

    I am have the same issue. I need to know if I need to do the change in the server. Which service account you should have access to?

    Regards

    Abdul 

    Tuesday, September 15, 2015 7:49 PM
  • This solved my problem too. Thank you!
    Thursday, April 5, 2018 9:29 AM
  • I did your modification and its true the error is gone but after i request the excel file on the server the browser is loading like it wont finish loading. What happened after that modification?
    Monday, October 22, 2018 9:24 AM
  • Hi,

    it's a 2 year's post, but thank you so much!

    It solved my problem, I'd never found on my own.

    Thanks

    Sunday, September 6, 2020 8:30 AM
  • Hi,

    for anyone who may have the same problem : be careful if you are using a 'sustem' user. You must log in Windows session with this user to allow Office install to complete.

    Logged once, I could delete the action mentioned above, having Interop working properly.

    HIH


    Sunday, September 13, 2020 8:52 AM