Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Excel workbook with 14 userforms (each one is for entering a slightly different type of data). The workbook has been behaving strangely--the Excel application quits whenever I close a form. I'd like to copy all of the forms into another workbook, so I can see if it's a corrupted workbook or if the problem is in my code. But in the VBE I can only copy one form at a time. Is there a better way to copy several forms at once?

share|improve this question
drag and drop ? – chris neilsen Dec 29 '11 at 1:59
no, that only lets you do one at a time. you can't select all the forms at the same time and then drag them all like you would with files in Windows Explorer. – sigil Jan 17 '12 at 21:46

The best thing I've found for fixing Excel files with corrupted macro binaries is the free VBA Code Cleaner. Installing it will add a Clean Project... option to the VBE Tools menu.

  1. Open the problem file in Excel.
  2. In the VBE, select Tools -> Clean Project...
  3. Select the workbook you want to clean and click OK.
  4. When it is done, recompile the macro and save.

If that doesn't work or you really want to move all the modules out of the existing Excel file into a new file, the other thing I use is the Source Tools Addin. If you want this to always be available, save it to %APPDATA%\Microsoft\Excel\XLSTART\. SourceTools adds a toolbar to the VBE.

  1. Open the problem file in Excel and show the VBE.
  2. In the Project Explorer, select the project name of the problem file.
  3. Click the diskette icon on the SourceTools toolbar. (This will save all modules to a [filename].src folder. i.e. C:\Data\Test.xlsm will now have a C:\Data\Test.xlsm.src\ folder.)
  4. Create a new workbook and click the open folder icon on the SoruceTools toolbar.
  5. Select the source folder just created.
  6. You will need to manually copy over any code in ThisWorkbook and any Sheet modules.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .