none
Open a excel file through Com-interop C# API on microsoft HPC RRS feed

  • Question

  • 'm working on a Windows HPC and I'm trying to make a small program which runs Excel's macro on the grid. I'm using the Com Interop API in C#
    The program runs well on my computer localy, it runs also well directly on the compute node but when I'm using the scheduler I have this exception (translated from french) :

    Exception Found: Type: System.Runtime.InteropServices.COMException Message: Microsoft Office Excel can't access the file

    \server\path\test.xls. There is multiple possibilities :

    • The file's name or the path doesn't existe
    • The file is currently used par another program
    • The workbook you are trying to use has the same name of another workbook already open

    Source: Microsoft Office Excel

    Stacktrace: 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) at namespace.ExcelFile.readExcel(Application excelApp) in E:\path\ExcelFile.cs:line 37

    Here is a snippet of my code :

    using Excel = Microsoft.Office.Interop.Excel; Excel.Application excelApp = new Excel.Application();

    if (!File.Exists(path))
        throw new System.IO.FileNotFoundException(path);

    workBook = excelApp.Workbooks.Open(path.Trim(), Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); excelApp.Visible = true; foreach (Command command in commands) { if (command.isMacro) command.RunMacro(getFileName(), excelApp); else command.runCommand(workBook); } workBook.Save(); workBook.Close();

    I've tried a few things:

    • Run locally
    • Run directly on the compute node
    • Impersonate the code, so I know i have the authorizations (I can access the file with the same account through windows explorer)
    • Check if the file exist first, check if i can copy it with File.Copy("","") in order to verify the right on the file
    • check how many workbook were open in ExcelApp (always 0 before I try to open the workbook)

    It seems that the problem is the scheduler, it must change something beside the account. What could it be ?

    What test could I do ?

    Thanks

    Thibaut

    Wednesday, March 6, 2013 4:30 PM