Hello fellow programmers.
I am working on a project that is a windows service. It should open an excel file and read it and it worked good on WinXP SP2 w/ Office 2003. Now the customer upgraded to Windows Vista 32-bit w/ Office 2007 and keep getting the following error:
--------------------------------------------------------------------------------------------------
SOURCE: Microsoft Office Excel
MESSAGE: Microsoft Office Excel cannot access the file 'C:\ProgramData \DataProcApplic ation\DataFile. xls'. 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 made sure the file exist and is in the correct folder. I gave admin privileges to the file and the folder, i run the service as admin and nothing seems to work. Now, i am sure the problem isn't in the file itself, since it's there. I also save some other binary files in that folder which the service can read/write to. As i assigned admin privileges, i can successfully read/write to a file in another path (not just isolated storage) like c:\somefile.txt .
So, i'm pretty sure the problem is with the excel interop, just cant really get it. This is the function that throws exception:
I've been trying to solve this all day long and trying to find a solution online with no luck. I saw posts with the same question though, but no answer. So, if anyone have a solution for this, please help me out.
Any help is greatly appreciated.
Cheers
I am working on a project that is a windows service. It should open an excel file and read it and it worked good on WinXP SP2 w/ Office 2003. Now the customer upgraded to Windows Vista 32-bit w/ Office 2007 and keep getting the following error:
--------------------------------------------------------------------------------------------------
SOURCE: Microsoft Office Excel
MESSAGE: Microsoft Office Excel cannot access the file 'C:\ProgramData \DataProcApplic ation\DataFile. xls'. 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 made sure the file exist and is in the correct folder. I gave admin privileges to the file and the folder, i run the service as admin and nothing seems to work. Now, i am sure the problem isn't in the file itself, since it's there. I also save some other binary files in that folder which the service can read/write to. As i assigned admin privileges, i can successfully read/write to a file in another path (not just isolated storage) like c:\somefile.txt .
So, i'm pretty sure the problem is with the excel interop, just cant really get it. This is the function that throws exception:
Code:
Workbook wb = excelApp.Workbooks.Open( path, 2, // UpdateLinks 1, 2, 3 true, // True to open the workbook in read-only mode. 1, // If Microsoft Excel is opening a text file, this argument specifies the delimiter character, as shown in the following table. If this argument is omitted, the current delimiter is used. null, // Password string null, // WriteResPassword string true, // IgnoreReadOnlyRecommended XlPlatform.xlWindows, // Origin ";", // Delimiter false, // Editable for add ins? false, // Notify 1, // Converter ??? false, // AddToMru true, // Local Microsoft.Office.Interop.Excel.XlCorruptLoad.xlNormalLoad); // CorruptLoad
Any help is greatly appreciated.
Cheers
Comment