0

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.

user4818954
  • 11
  • 1
  • 4
  • 1
    First try overwriting existing excel with shapes, if it still does not works check in your system by creating a new excel file & copy the same shapes & try saving. If it gets saved, then it is code enhancement. – Shubhojit Apr 22 '15 at 11:09

1 Answers1

0

Save your OutputWorkbook. Reopen it and then try to copy. See if it works.

CDP21
  • 18
  • 4