Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I do this in Excel 2010 this fails, but works in Excel 2007:

  1. Create a new workbook and insert an image onto a worksheet, or get a preexisting worksheet with an image.
  2. Copy the worksheet into a new workbook by clicking the worksheet tab and clicking Move Or Copy and then choosing (new workbook) as the destination.
  3. Close the source workbook.
  4. Attempt to save the new workbook.

The message is: "Errors were detected while saving 'myfilepathhere.xlsx'. Microsoft Excel may be able to save the file b removing or repairing some features. To make the repairs in a new file, click Continue. To cancel saving the file, click Cancel". Clicking continue brings up another file dialog window followed by more repair errors.

It seems behind the scenes it is looking to the source workbook when it tries to save the image in the new destination workbook. No useful error message, of course, thanks microsoft. But this problem never happened in Excel 2007.

The reason why I am closing the source notebook before the save, is because I don't need the end user to see it after I programmatically pull a coversheet (with the image) from it, in an interop app.

Thanks for any help.

Update: I don't encounter this problem if I open the source workbook as "Read Only" (I do this programmatically using Excel Interop).

share|improve this question
    
Are you sure the problem is caused by closing the source document? –  user3463 Dec 7 '11 at 1:25
    
@RandolphWest : Yes, pretty sure. When the source workbook is open, the destination workbook saves with no error messages. When the source workbook is closed, the destination workbook won't save properly. Maybe in Excel 2007, doing a worksheet copy to a new workbook copies the embedded image right away... but in 2010 it looks to the source document when you go to save. Also it doesn't matter/still breaks the destination save when I do a worksheet.copy in C# interop, and also when I recreate it manually using the above steps in Excel. Thanks. –  snorehorse Dec 7 '11 at 23:40
    
So the obvious answer is to not close the source document until you've finished processing it. Or change the code to paste-special, which pastes a copy of the image(s) and not a link to the image(s), if that's what the problem is. –  user3463 Dec 8 '11 at 5:29
    
I don't want a situation where the end user can close the source workbook, and thereby break the destination workbook save. I'd rather not even show the source workbooks to the end user, which I didn't have to do, until I encountered my problem with Excel 2010. If I wanted my user to save their programmatically created workbook, I'd have to keep all the source docs open so that the destination would save properly. –  snorehorse Dec 8 '11 at 17:12
1  
You may need to rethink the way you're doing this anyway. There are multiple points of failure in the process. That of course is outside the scope of this question. –  user3463 Dec 8 '11 at 23:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.