I wrote up a method that takes all the cells from a DataGridView and copies them to an Excel workbook.
It all works fine and dandy, up until I get to the part where I actually save it.
Here is the code that saves it:
//Saves the Workbook to the specified path
excelWorkbook.ActiveWorkbook.SaveCopyAs(pathToSave);
excelWorkbook.ActiveWorkbook.Saved = true;
//Close the workbook
excelWorkbook.Quit();
And the exception being thrown:
Microsoft Office Excel cannot access the file 'C:\Users\TheGateKeeper\Desktop\New folder'. 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.
This is the first time I am working with this class, so I may have messed something up.
Also as a sidenote, what does:
excelWorkbook.ActiveWorkbook.Saved = true;
do?
Thanks.