This may be more of an Excel question than InfoPath, but this forum has always been very useful and perhaps someone can help.
From an InfoPath form I use an OpenFileDialog to open an Excel workbook and then retrieve some data to put in xml. Afterwards I close the Excel file. The problem is that until InfoPath is completely closed, if I try to open that workbook by itself, I get a message that it is locked for editing.
Below is my open/close code. Is it something I am missing or doing wrong here? Thanks for any help
// Open MS Excel and the selected workbook
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook workBook = app.Workbooks.Open(
diag.FileName, // FileName
0, // UpdateLinks
true, // ReadOnly
missing, // Format
missing, // Password
missing, // WriteResPassword
true, // IgnoreReadOnlyRecommended
missing, // Origin
missing, // Delimiter
missing, // Editable
missing, // Notify
missing, // Converter
false, // AddToMru
missing, // Local
missing); // CorruptLoad
//retrieve data...
if (workBook != null) workBook.Close(missing, missing, missing);
if (app != null) app.Quit();