保护 VBA 的更好方法比内置的 Excel 更好



我注意到XLSM文件的密码保护很容易被破坏,暴露所有VBA代码。

除了简单地在项目设置上添加密码保护之外,还有哪些替代方法可以提供更高的安全性?

对于任何有兴趣真正保护其 VBA 项目的人,请查看以下分步指南(收集和测试(。我发现它对我来说工作正常。

1. Open your desired file.
2. Press Alt+F11 to access the add-in's vba project
3. Lock the vba-project with a password
4. Double-click on the "ThisWorkbook" code module
5. Press F4 to open the Properties window
6. Change the "IsAddin" status to FALSE
7. Return to Excel by Pressing Alt+Q (or close the vbe window)
8. Go to Review TAB > Share Workbook
9. When the dialogue appears, check the box for: (Allow changes by.....)
10. Press OK to close the Dialogue
11. When prompted to save, Press OK
12. Press Ok to accept that "macros cannot be accessed"
13. You should feel giddy at this point because you just realized what you havebeen missing right under your nose
14. Verify that the [SHARED] appears in the application title bar
15. Now save the workbook again.
16. Close this Excel workbook.
17. Test out your newly saved file (open it, access the vba, try to expand the project window, you should get the new message "Project is Unviewable"
18. Your done

使您的 VBA 项目不可见

复制要使其无法查看的Excel文件(请记住 - 一旦这样做,就没有退路!(并将其扩展名更改为.zip。右键单击存档,然后转到使用WinRAR打开>双击XL文件夹并提取vbaProject.bin文件或将文件拖放到桌面上。解压缩后,右键单击该文件,使用记事本++打开。

对于 Excel 工作簿文件(在 .

xlsb 上测试(,您可以将括号之间的 CMG、DPB 和 GC 字符串替换为大于或等于原始字符串中字符数的任意偶数"F",对于加载项文件(在 .xlam 上测试(,您需要将它们替换为与原始字符串中的字符数完全相同的"F"数。

保存更改关闭Notepad++并将文件拖放回存档中,以将原始文件替换为更新的文件。

将扩展名从.zip更改回原始 Excel 文件扩展名(.xlsb、.xlam 等(。现在,当您打开文件时,请转到VB编辑器并尝试展开VBA项目。您应该看到一条消息,指出项目不可查看,而不是密码提示。

您的项目现在无法破解。没有人(甚至您(可以看到或编辑VBA代码。

相关内容

最新更新