Excel Interopを使用するコンソールプログラムをC#.NETで開発しました。このプログラムは、コマンドラインから実行した場合、開発マシンとWindowsServer2008で問題なく動作します。
タスクを毎日実行するようにスケジュールしようとすると、この厄介な相互運用エラーが発生しました。
02/11/2011 00:30:05,000 [1] FATAL My.Program [(null)] - Unable to Microsoft Office Excel open file 'E:\excel.xls' by one of several 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 the currently opened book.
System.Runtime.InteropServices.COMException (0x800A03EC): Unable to access the Microsoft Office Excel file 'E:\excel.xls' by one of several 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 the currently opened book.
in Microsoft.Office.Interop.Excel.Workbooks.Open (String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, IgnoreReadOnlyRecommended Object, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
ファイル'e:\ excel.xls'が存在し、プログラムの開始時に完全に閉じられた場合、コマンドラインで同じプログラムを実行しようとすると、期待どおりに終了したためです。
また、管理者として実行するようにタスクを設定したので、権限の問題ではないはずです。
手伝って頂けますか?