Background: I am using the Microsoft.Office.Interop.Excel libraries to open, manipulate, and save excel files in my Windows Form program. For reasons I won't fully go into, I need the information presented on the screen at any one time to be minimal, so I am using DataTables and DataGridViews to manipulate the information stored in the excel file. I can pull in and edit the information just fine, but my issue is with saving.
My Issue:
When attempting to save back out to the excel file using the WorkBook.Save() function, the changes are not reflected when I open the file in Excel. As a test, I tried the .SaveAs() function to see what was up and got the error that the original file was opened in read-only mode. I used the .SaveCopyAs() function to ensure my information was being outputted correctly, and the saved copy contained the changes I made.
I have attempted every possible combination of any and all read-only and save properties I could find, and the following two properties seem to solve the issue for most other people but will not work for me.
xlWorkBook = xlApp.Workbooks.Open(currFile, IgnoreReadOnlyRecommended:=True, ReadOnly:=False)
My code is spread out across several functions as I am using buttons and menu items to operate the program, but it follows the same workflow as the Save example from this website, except I set xlApp.Visible = False
: http://www.siddharthrout.com/2012/09/12/saving-and-closing-the-excel-file-savesave-as-method/.
I'd appreciate any help.
Edit: Forgot to mention, I am using Excel 2010, and Visual Studio 2015 with the VB Windows Form Application template.