VBA Project Password-Protect with SendKeys not Working Correctly

江枫思渺然 提交于 2019-11-29 08:40:39
ARich

Ok, so after another couple of hours of searching the web for alternative methods to achieve my goal, I stumbled across this post.

I created a template workbook (with the event code already in ThisWorkbook), password protected the project, and modified my code to use the template workbook for each new sheet. Now when the sheets are created, the project is already locked for viewing and requires a password. While I realize the security under this approach isn't very secure, it will help "keep honest people honest" as they say.

For those who stumble across this post and still wish to programmatically lock/unlock their VBA Project, see these resources:

This SO post
This blog

Both are great resources that walk through a way to do it in VBA.

To add a nuance to the otherwise fine piece of code originally posted here: If you change the Project Name for the workbook within the VBE, you'll need to change one line of code to:

   .VBE.CommandBars("Menu Bar").Controls("Tools") _
        .Controls(VBP.Name & " Properties...").Execute

(sigh)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!