• VBA damage in Excel (Excel 2003/XP)

    • This topic has 6 replies, 3 voices, and was last updated 17 years ago.
    Author
    Topic
    #450643

    Hi everybody:

    I recently had a user experience an Excel crash because he had AutoSave turned on and it tried to save his file at the exact moment that he triggered some VBA code. The file was recoverable, but now one of the VBA routines keeps getting called over and over after the calling code in the Sheet_Recalculate event exits. I know how to recover damaged VBA projects in Access by opening the file decompiled and then compacting it, but does anyone know of a way to recover damaged Excel VBA sheet modules? (Deleting and recompiling didn’t help.)

    Thank you, in advance, for your help.

    Viewing 1 reply thread
    Author
    Replies
    • #1107617

      Do you mean that you have deleted the worksheet code and this didn’t help?

      • #1107631

        Hi Hans:

        My first line of defense was to delete the VBA code, save the workbook, open and repair it, add the VBA code back in and compile. This did not solve the problem. So, I created a new workbook and copied and pasted everything into it, added the VBA code, and it is fine now. Apparently, the worksheet was damaged by the Autosave process crashing my VBA.

        I was just wondering if there is a way to repair Excel VBA projects as one can with Access.

        Thanks for your help.

        • #1107632

          The problem with worksheet modules (and with ThisWorkbook) is that you cannot completely delete them – you can only delete their contents. This leaves behind the invisible corruption. There is no /decompile option for Excel.
          The way you solved it is the best one.

    • #1107618

      Try running Code Cleaner on it – you can get it here: http://www.appspro.com/Utilities/CodeCleaner.htm%5B/url%5D
      If that doesn’t work, you may need to copy the data and code modules to a new workbook.

      • #1107630

        Thanks, but there is very little code to be cleaned (three functions!). It appears that the VBA project itself is damaged.

    Viewing 1 reply thread
    Reply To: VBA damage in Excel (Excel 2003/XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: