从 VBA 项目中删除密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/272503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Removing the password from a VBA project
提问by Barry-Jon
How can I programmatically remove a (known) password from an Excel VBA project?
如何以编程方式从 Excel VBA 项目中删除(已知)密码?
To be clear: I want to remove the password from the VBA Project, not the workbook or any worksheets.
需要明确的是:我想从 VBA 项目中删除密码,而不是工作簿或任何工作表。
采纳答案by Jon Fournier
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
这有一个使用 SendKeys 来取消保护 VBA 项目的简单方法。这将使您进入该项目,因此您必须继续使用 SendKeys 找出删除密码保护的方法: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
这是一种使用更先进、更可靠的解除保护方法的方法。同样,它只会为您解锁 VB 项目。 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...
我还没有尝试过任何一种方法,但是如果您需要这样做,这可能会为您节省一些时间......
回答by Uygar Y
Another way to remove VBA project password is;
删除 VBA 项目密码的另一种方法是;
- 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.
- 使用十六进制编辑器打开 xls 文件。(即十六进制编辑http://www.hexedit.com/)
- 搜索 DPB
- 将 DPB 替换为 DPx
- 保存存档。
- 在 Excel 中打开文件。
- 如果您收到任何消息框,请单击“是”。
- 从 VBA 项目属性设置新密码。
- 关闭并再次打开文件,然后输入您的新密码以取消保护。
UPDATE:For Excel 2010 (Works for MS Office Pro Plus 2010 [14.0.6023.1000 64bit]),
更新:对于 Excel 2010(适用于 MS Office Pro Plus 2010 [14.0.6023.1000 64bit]),
- Open the XLSX file with 7zip
- 用 7zip 打开 XLSX 文件
If workbook is protected:
如果工作簿受保护:
- Browse the folder
xl - If the workbook is protected, right click
workbook.xmland select Edit - Find the portion
<workbookProtection workbookPassword="XXXX" lockStructure="1"/>(XXXXis your encrypted password) - Remove
XXXXpart. (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 Workbookon Reviewtab.
- Optional: Save your file.
- 浏览文件夹
xl - 如果工作簿受保护,请右键单击
workbook.xml并选择编辑 - 找到部分
<workbookProtection workbookPassword="XXXX" lockStructure="1"/>(XXXX是您的加密密码) - 删除
XXXX部分。(即。<workbookProtection workbookPassword="" lockStructure="1"/>) - 保存文件。
- 当 7zip 要求您更新存档时,请说Yes。
- 关闭 7zip 并重新打开您的 XLSX。
- 单击“审阅”选项卡上的“保护工作簿”。
- 可选:保存您的文件。
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 Sheeton Reviewtab.
- Optional: Save your file.
- 浏览到
xl/worksheets/文件夹。 - 右键单击
Sheet1.xml,sheet2.xml等,并选择编辑。 - 找到部分
<sheetProtection password="XXXX" sheet="1" objects="1" scenarios="1" /> - 删除加密密码(即。
<sheetProtection password="" sheet="1" objects="1" scenarios="1" />) - 保存文件。
- 当 7zip 要求您更新存档时,请说Yes。
- 关闭 7zip 并重新打开您的 XLSX。
- 单击“审阅”选项卡上的“取消保护工作表”。
- 可选:保存您的文件。
回答by Joji Thomas Eapen
I found another way to solve this one to avoid password of VBA Project,with out loosing excel password.
我找到了另一种方法来解决这个问题,以避免丢失 VBA 项目的密码,而不会丢失 excel 密码。
use Hex-editor XVI32for the process
使用十六进制编辑器 XVI32进行该过程
if the file type is XLSM files:
如果文件类型是 XLSM 文件:
- Open the XLSM file with 7-Zip (right click -> 7-Zip -> Open archive).
- 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.
- 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
- 使用 7-Zip 打开 XLSM 文件(右键单击 -> 7-Zip -> 打开存档)。
- 将xl/vbaProject.bin文件复制出文件(可以从7-Zip拖拽),不要关闭7-Zip
- 使用 HexEdit 打开 vbaProject.bin 文件
- 搜索“DPB=”并将其替换为“DPx=”
- 保存文件
- 将此文件复制回 7-Zip(同样,拖放工作)
- 在 Excel 中打开 XLSX 文件,如果提示“继续加载项目”,请单击“是”。如果出现错误提示,请单击“确定”。
- 按 Alt+ F11 打开 VBA 编辑器。
- 按下它会显示错误“意外错误(40230)”,只需单击“确定”(6 或 7 次)直到它消失。
- 然后它会自动打开
回答by JFV
回答by Aveesh
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.
在用 7 zip 打开 xlsm 文件,提取 vbaproject.bin 并在 Notepad ++ 中用 DPx 替换 DpB 并重新保存后,我遇到了很多 vbaproject 错误,vba 项目密码不见了,但没有代码/表单。
I right clicked to export and was able to re-import to a new project.
我右键单击导出并能够重新导入到新项目。

