Excel file "locked for editing" after importing from InfoPath - InfoPath Dev
in

InfoPath Dev

Excel file "locked for editing" after importing from InfoPath

Last post 07-13-2009 01:32 PM by b.harrison. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 07-13-2009 01:32 PM

    Excel file "locked for editing" after importing from InfoPath

    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();

    Filed under:
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.