无法访问未使用的excel文件

我得到这个错误消息

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Excel cannot access the file '\\<NetworkPath>\<excelName>.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. 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) 

使用互操作的需要是,我有一个兼容的Excel网页(.XLHTML)而我需要将该文件转换为.XLSX,因为我想读取该文件,并与信息内工作。

所以我find了一个办法,写了一个程序

 static string ConvertExcelToXlsx(string excelFilePath, string tempDir) { // get new extension string xlsxFilePath = tempDir + Path.GetFileNameWithoutExtension(excelFilePath) + ".xlsx"; /* delete temporary excel if exists */ File.Delete(xlsxFilePath); // save original .XLHTML to new .XLSX format Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application(); excelApp.Visible = false; Microsoft.Office.Interop.Excel.Workbook eWorkbook = excelApp.Workbooks.Open(excelFilePath, 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); eWorkbook.SaveAs(xlsxFilePath, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); eWorkbook.Close(false, Type.Missing, Type.Missing); // return file path to new .XLSX file return xlsxFilePath; } 

在我的testing中,在我的本地PC和服务器上,它工作正常,但现在没有,我得到上面的错误信息。

我试图从sysinternals运行程序来查找该文件是否被另一个进程使用http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx

Handle.exe originalExcel.xls(扩展名是.xls,但实际上是.xlhtml)

但它说它没有被其他进程使用,filePath是正确的。 所以错误消息的最后一个项目符号是The workbook you are trying to save has the same name as a currently open workbook. “但是在桌面上没有打开的excel文件,在任务pipe理器中,我也没有看到excel进程,那么可能是一个问题,我该如何解决呢?

谢谢

PS:所有系统都安装有Excel的Windows 7。