I am using Interop.Excel in my WinForms application. The application is used to copy some sheets from one workbook to newly created one.
The newly created workbook is saved when I don't copy shapes. But, when I copy shapes into newly created sheet, the workbook is not saved and COMException is raised with message "Document not saved".
Scenario :
I am working with three workbooks simultaneously.
MainWorkbook - this workbook contains data to be written into new workbook.
ResourceWorkbook - this contains sheets that are copied into new workbook.
OutputWorkbook - this is the result workbook.
Step 1: Open MainWorkbook. Get data to write in OutputWorkbook.
Step 2: Write data into OutputWorkbook.
Step 3: Open ResourceWorkbook from resource file for copying the sheets.
Step 4: Copy sheets from ResourceWorkbook into OutputWorkbook.
Step 5: Save OutputWorkbook.
In step 5, if there are no sheets with images copied in step 4, then the OutputWorkbook is saved. But, if there are sheets containing images, the OutputWorkbook is not saved.
I am using VS2010 and MS Office 2010.
Save your OutputWorkbook. Reopen it and then try to copy. See if it works.