How can I programmatically remove a (known) password from an Excel VBA project?
To be clear: I want to remove the password from the VBA Project, not the workbook or any worksheets.
How can I programmatically remove a (known) password from an Excel VBA project?
To be clear: I want to remove the password from the VBA Project, not the workbook or any worksheets.
Another way to remove VBA project password is;
UPDATE: For Excel 2010 (Works for MS Office Pro Plus 2010 [14.0.6023.1000 64bit]),
If workbook is protected:
xlworkbook.xml and select Edit<workbookProtection workbookPassword="XXXX" lockStructure="1"/> (XXXX is your encrypted password)XXXX part. (ie. <workbookProtection workbookPassword="" lockStructure="1"/>)If worksheets are protected:
xl/worksheets/ folder.Sheet1.xml, sheet2.xml, etc and select Edit.<sheetProtection password="XXXX" sheet="1" objects="1" scenarios="1" /><sheetProtection password="" sheet="1" objects="1" scenarios="1" />) 
    
    I found another way to solve this one to avoid password of VBA Project, without losing password.
If the file type is XLSM files:
.xlsm as .zip (or you can open the .xlsm with 7zip/WinRAR) and open/extract itxl/vbaProject.bin file with Notepad++ or HexEditDPB= and replace it with DPx=.zip (or zip the files back up).xlsm.xlsm fileor
Follow this Step Also
I found another way to solve this one to avoid password of VBA Project, without losing excel password. use Hex-editor XVI32 for the process
if the file type is XLSM files:
Open the XLSM file with 7-Zip (right click -> 7-Zip -> Open archive). 2. Copy the xl/vbaProject.bin file out of the file (you can drag and drop from 7-Zip), don't close 7-Zip
Open the vbaProject.bin file with HexEdit
Search for "DPB=" and replace it with "DPx="
Save the file
Copy this file back into 7-Zip (again, drag and drop works)
Open the XLSX file in Excel, if prompted to "Continue Loading Project", click Yes. If prompted with errors, click OK. 8. Press Alt+ F11 to open the VBA editor.
While press it will show error “Unexpected error (40230)”, just click OK (6 or 7 times) until it goes away.
Then it will open Automatically
 
    
    This has a simple method using SendKeys to unprotect the VBA project. This would get you into the project, so you'd have to continue on using SendKeys to figure out a way to remove the password protection: http://www.pcreview.co.uk/forums/thread-989191.php
And here's one that uses a more advanced, somewhat more reliable method for unprotecting. Again, it will only unlock the VB project for you. http://www.ozgrid.com/forum/showthread.php?t=13006&page=2
I haven't tried either method, but this may save you some time if it's what you need to do...
 
    
    My 2 cents on Excel 2016:
xls file with Notepad++DPB= and replace it with DPx=error 40230) 
    
    After opening xlsm file with 7 zip, extracting vbaproject.bin and in Notepad ++ replacing DpB with DPx and re-saving I got a Lot of vbaproject errors and vba project password was gone but no code/forms.
I right clicked to export and was able to re-import to a new project.
 
    
    