locked
Microsoft Excel cannot access the file RRS feed

  • Question

  • User-1044445836 posted

    Hi...

    While dealing with excel I am getting following error:

    Microsoft Excel cannot access the file 'C:\trng\abc.xslx'. 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 guess this is due to improper disposing of excel application.

    Please tell me how to dispose an excel application properly

    Thanks..

    Monday, April 16, 2012 8:13 AM

All replies

  • User-1965373247 posted

    Can this not be done from the Task Manager?

     

    Regards

    Monday, April 16, 2012 9:05 AM
  • User-1044445836 posted

    Hi 

    thanks for reply:)

    I killed "EXCEL.EXE" from task manager as well as by using code.But problem still persists...

    try
    {
    eapp = new Microsoft.Office.Interop.Excel.Application();
    workbook = eapp.Workbooks.Open(datasource,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing);

    excelSheets = workbook.Worksheets;
    excelWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item("sheet1");
    int index = Convert.ToInt16(Session["id"]);

    ..........................................

    ..........................................

    }

    catch (Exception ex)
    {

    ClientScript.RegisterStartupScript(this.GetType(), "script", "alert('" + ex.Message + "');", true);
    }
    finally
    {
    workbook = null;
    excelWorksheet = null;
    eapp.Quit();
    eapp = null;

    }


    I have ensured that there is no "EXCEL.EXE" running before entering into try block but still it gives the same error..


    Tuesday, April 17, 2012 5:23 AM
  • User-1044445836 posted

    and one more thing i would like to tell that evrthng is fine when i am using VS 2010 inbuilt server.The problem pops up when i try to deploy the site over IIS 7.5.

    Tuesday, April 17, 2012 6:08 AM
  • User3866881 posted

    Hello mannn:)

    Considering it that your issue doesn't belong to AccessDataBase,So I suggest you trying to ask question at MSDN's Office programming,and you can get more help there:

    http://social.msdn.microsoft.com/Forums/en-us/exceldev/threads

    Tuesday, April 17, 2012 9:36 PM
  • User-1044445836 posted

    hiii Decker Dong-MSFT

    Thanks for your suggestion Smile

    Wednesday, April 18, 2012 1:09 AM
  • User3866881 posted

    hiii Decker Dong-MSFT

    Thanks for your suggestion Smile

    No problem,my pleasure to correct you to a right place to ask……:-)

    Wednesday, April 18, 2012 1:10 AM