"Errors were detected while saving..." only after I run a vba macro and save RRS feed

  • General discussion

  • This is specific to this workbook I'm working on which has a vba macro on a XP Pro SP3 w/ Excel 2010
    The behavior is basically, I open the workbook and run the macro.  When it finishes, I save the workbook.  And when I reopen the workbook and try to save again, I get the error.  And as some of you may know, I can't just continue and try to save because the resulting workbook is completely garbaged.

    If do not run the macro, I do not have this issue.  Also, I found out that when I open this workbook in Excel 2007, it opens and saves fine.  Stranger even, when I open the workbook that was saved in 2007, I can open it and save it just fine once again.

    This particular issue doesn't seem to be specific to 2010 although it's more reproducible in 2010 in that it happens every time.  I was also able to reproduce this bug in 2007 but not every time.  But when it does happens on 2007, I can take the workbook and open it in 2010 and voila, it opens and saves ok.  So this "corrupted" workbook can be opened by the other versions.  It's like a ping-ping match.

    I also noticed that when I run the macro, it takes a significant time to "finish" - meaning there is a big delay after the macro finishes and gives the control to the user.  I am assuming that there is some kind of cleaning up going on.  This delay wasn't there from the beginning but it started at some point during the development as my codebase got bigger.

    The other thing I noticed is that there are two parts of the macro or two separate macros I run.  The first one is purely functional, meaning there are no class modules involved, while the second macro uses class modules extensively w/ all its "fake" polymorphism/inheritance implementations via interface, etc.  The reason I mention this is that when I run the first macro and save, the corruption does not occur while the second macro does.  So I have a suspicion that it might be related to that - perhaps objects not getting garbage-collected correctly.

    Anyone have an idea?
    • Changed type 许阳(无锡) Monday, October 22, 2012 4:06 AM No clearly goal
    Monday, October 15, 2012 3:25 PM

All replies

  • Hi Jiho,

    Thanks for posting in the MSDN Forum.

    Would you please provide more detailed scenario for further research? I think show your vba snippet which relate to this issue is the basic request for further research.

    Have a good day,


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, October 16, 2012 4:43 AM