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.
Tools needed: An archive tool like 7zip as normal compression won't work.
I cannot guarantee that it will work for your file but following procedure successfully worked for me.
- Create a temporary working folder and copy the original file here (1150459.xlsm), so you are working on a backup copy in an isolated folder.
- Also create another empty macro enabled workbook. Do not forget to insert an empty standard module in this new workbook and save it with this dummy module (Book1.xlsm).
- Change the original workbook names by adding .zip extension to the full file names.
- Right click on the original file, and Extract All. You will have a folder called as the workbook file name:
- Right click on the Book1.xlsm, and select 7zip->Open Archive.
- The archive will be opened in the 7zip explorer window. Go to
xl
folder in this window, and locate the vbaProject.bin
file.
- Go back to the previously extracted folder in Windows explorer, go to the same path,
xl
, and find the same file, vbaProject.bin
. Make sure keeping the 7zip explorer window accessible as you'll move this particular file into the 7zip explorer window. Basically keep them side by side.
- Drag the
vbaProject.bin
file and drop in the Book1.xlsm.zip/xl/
folder in the 7zip explorer window. It will ask for overwrite confirmation. Accept it. Quit 7zip.
- Rename Book1.xlsm.zip as Book1.xlsm, and try to open the file.
Note: Actually you can skip renaming the file names by adding .zip extension, and open both xlsm file in 7zip as archive, drag necessary file from the original to the Book1.xlsm directly, however it sometimes doesn't work due to different platforms or versions, so I tried to explain with rename procedure.