Corrupt Load Vba Macro Excel Code
Close the corrupted workbook if opened. In Excel, click FilegtOpengtBrowse. Navigate to the location and folder that contains the corrupted workbook. In the Open dialog box, select the corrupted workbook. Click the arrow next to the Open button, and then click Open and Repair.
As an additional suggestion to Fluff's suggestions which will likely solve the problem quicker, a VBA project can be extracted, and copied to another workbook without opening it in Excel. However, it wouldn't work for the Excel files saved in the older versions, older than 2010 perhaps. Obviously, the VBA project will remain locked if it is password protected in the original workbook.
The above issue is for any excel workbook even with a simple macro. Solution Rename the corrupted file amp open it --gt Do not Enable Macros --gt Go to the VBA window you could see the code now ! --gt Save the file amp close it --gt Again rename to the original and open .. it starts working normally. No need to repair.
There are a number of third-party tools that can help you recover corrupted files. Here a workaround that you can try in the meantime. Here are the steps on how to use the workaround Open the corrupted workbook. Disable macros. Save the workbook as a .zip file. Open the .zip file, and then open the workbook. Enable macros.
Close the corrupted workbook. Create a new workbook or open the workbook in which you want to use the macros Open the VBA editor AltF11 Right-click on the VBA Project that has the filename of your workbook, and select Import File'. Navigate to the exported VBA module and click Open. The module will now be a part of your workbook.
Thank you for the help on this one. This works with Office 365 also. I had an excel file with a huge amount of data and macros, forms modules etc. Hours of work which I thought I had lost. The advice to rename, open not activate macros but first open VBA editor and compile the code worked perfectly.
Excel 2019, with 2 workbooks. I have a macro-enabled workbook with 1 worksheet with 1 query and VBA code that refreshes the query, copies the sheet, opens a second .xlsx workbook, pastes the sheet, deletes the query from the .xlsx file, then closes the .xlsx file with WBPost.Close SaveChangesTrue. The .xlsx file is only 20KB.
- VBA is completely unusable in the Excel workbooks that have been corrupted. I can't remove the code if I wanted to since I can't see the code. I can't write new code either. The quotwindowsquot of VBA are not operational in the corrupted workbooks. - The same code is used in a few other workbooks that are still fully operable, for now.
In most cases, I can step around this by changing the parameters on the CorruptLoad either to xlRepairFile or xlExtractData. But therein lies the chicken and the egg problem. If I try to load it as xlNormalLoad and the file is corrupt, then the procedure stops and I have to manually change the code until I can get the excel to open.
Name Value Description xlExtractData 2 Workbook is opened in extract data mode. xlNormalLoad 0 Workbook is opened normally. xlRepairFile 1 Workbook is opened in repair mode.