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;
Open xls file with a hex editor.
(ie. Hex Edit http://www.hexedit.com/)
Search for DPB
Replace DPB to DPx
Save file.
Open file in Excel.
Click "Yes" if you get any message box.
Set new password from VBA Project Properties.
Close and open again file, then type your new password to unprotect.
UPDATE: For Excel 2010 (Works for MS Office Pro Plus 2010 [14.0.6023.1000 64bit]),
Open the XLSX file with 7zip
If workbook is protected:
Browse the folder xl
If the workbook is protected, right click workbook.xml and select Edit
Find the portion <workbookProtection workbookPassword="XXXX" lockStructure="1"/> (XXXX is your encrypted password)
Remove XXXX part. (ie. <workbookProtection workbookPassword="" lockStructure="1"/>)
Save the file.
When 7zip asks you to update the archive, say Yes.
Close 7zip and re-open your XLSX.
Click Protect Workbook on Review tab.
Optional: Save your file.
If worksheets are protected:
Browse to xl/worksheets/ folder.
Right click the Sheet1.xml, sheet2.xml, etc and select Edit.
Find the portion <sheetProtection password="XXXX" sheet="1" objects="1" scenarios="1" />
Remove the encrypted password (ie. <sheetProtection password="" sheet="1" objects="1" scenarios="1" />)
Save the file.
When 7zip asks you to update the archive, say Yes.
Close 7zip and re-open your XLSX.
Click Unprotect Sheet on Review tab.
Optional: Save your file.
I found another way to solve this one to avoid password of VBA Project, without losing password.
If the file type is XLSM files:
Rename the .xlsm as .zip (or you can open the .xlsm with 7zip/WinRAR) and open/extract it
Edit the xl/vbaProject.bin file with Notepad++ or HexEdit
Search for DPB= and replace it with DPx=
Save the file
Copy this file back into the .zip (or zip the files back up)
Rename the archive back to .xlsm
Open the file in Excel, if prompted to "Continue Loading Project", click Yes. If prompted with errors, click OK. Note: the code may still be blank or corrupted, which we fix in the next step
Save the file as a new .xlsm file
Open the new file in Excel (should be no errors now)
Press Alt+ F11 to open the VBA editor
or
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:
open the xls file with Notepad++
Search for DPB= and replace it with DPx=
Save the file
Open the file, open the VB Editor, open modules will not work (error 40230)
Save the file as xlsm
It works
I found this here that describes how to set the VBA Project Password. You should be able to modify it to unset the VBA Project Password.
This one does not use SendKeys.
Let me know if this helps!
JFV
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.
Related
There isn't enough memory to complete this action" in Excel
How to fix it without opening file
İ want to turn calculation manual but without open it is impossible
In order to change the automatic calculation to manual without opening the .xlsx file, you can do this. Before doing this, be sure to make a copy of the file and try these manipulations on the copy.
Unzip the .xlsx as a .zip archive, open the file ...\xl\workbook.xml in a text editor, find a tag similar to the following <calcPr calcId="191029"/> and add to it calcMode="manual" so you get <calcPr calcId="191029" calcMode="manual"/>. Then save this file, package the entire directory, and change the extension to .xlsx.
Is there a way to extract the macros from a closed workbook?
I have several macros that I'd like to keep, but the installation of Excel has become corrupted and I can no longer open the files that are already created. I am able to open new files, so now I need to extract the macros from my workbook so that I can continue to use them.
Any ideas?
Simple fix assuming it's an .XLSM file.
Rename it to a .ZIP
Open it and go to the xl folder. drag the vbproject.bin to your desktop
create a new blank sheet, rename that to zip, and drag the .bin file from your desktop into the xl folder. Rename file back to XLSm and the vb modules will be there.
A specific xlsm workbook crashes when I try to save, save as, or when I open the VBA editor. I've tried disabling macros, removing auto calculations, etc. I can't actually get to the code to see if there's a bug causing the crash due to the editor itself causing crashes.
Edit: Also forgot to mention there are links to another workbook in the file - but removing auto-updating/calculating upon save doesn't seem to help. Also, I'm able to modify the workbook, I just can't execute the macros, save, or open the VBA editor.
Edit2: Some additional info. I tried deleting all worksheets and still have the same problems so there must be something wrong in the code.
Looking for a solution to salvage the workbook.
Remove the VBAProject.bin file from the .xlsm file:
copy the .xlsm file
change the extension of the copy to .zip (say Yes to the warning about changing extensions)
open the ZIP file
open the xl folder
cut the VBAProject.bin file and paste it to somewhere outside the ZIP file
rename the ZIP file back to a .xlsm extension
You should now be able to open the .xlsm file in Excel but it will no longer have any macros.
It is theoretically possible to reconstruct the macros from the VBAProject.bin file using the resources linked to in this answer but this may involve considerable effort
I password protected an Outlook VBAProject and then subsequently forgot the password. Luckily, I exported the VBA code, but I'd like to unprotect the VBAProject.otm file.
I saw online how to do this for Excel projects, but not for Outlook VBA. Any ideas? Tks!
Try using VBA Password Recovery Master.
Also see Download VBA Password Recovery Free Software- Get VBA Password Again!.
Try using the Hex Editor option. Open the OTM file in Hex Editor and try changing the DPB to DPx and save the file and then try opening the vba in outlook.
Note: use the above by creating a copy of OTM file ot it might get corrupted.
I'm writing VBA codes for multiple Excel spreadsheets, which will be shared with others from time to time. At some point I find there are lots of duplications in my works. So I want to find a way to share codes in a sort of Excel add-in, like the .xla file.
But when I tried to save the Excel file containing shared codes as .xla file, I got some problems:
The file cannot be edit anymore after I save it in the default add-in folder
If I move the .xls file to a folder other than the add-in folder, and open it directly - I cannot use its classes - which creates problems for sharing the codes
Any ideas to create add-ins in a flexible and powerful way please?
Thanks a lot for the help
Not completely sure this is what you're looking for, but ...
(1) save the .xla/.xlam code by clicking the save icon in the VBA editor. HOWEVER, the thing that saves is the thing currently selected in the Project Explorer pane, which lists all open VB Projects and which is usually on the left. Even if you are staring at your just-edited VBA code, clicking the save icon will not save your code unless it is also selected in the Project Explorer pane. You won't get feedback that anything was saved - but you can verify by checking the file timestamp in a separate window.
(2) if you have an *.xls file which (via the formula bar) refers to VBA functions from your *.xla / *.xlam file, then if you open the *.xls file without opening the .xla,.xlam file first, Excel may create external links to resolve the formulas (i.e. referring to a file which is not open). If you have moved or renamed the *.xla file you can get stuck with those "mangled formulas" and need to edit out the pathname links that Excel inserted using a global substitute. If you arrange to open the .xla,.xlam prior to any *.xls file that uses it, you shouldn't have a problem (e.g. by using the default folder).