使用VBA从第一个密码保护第二个工作簿的宏 [英] Password-protect the macros of a second workbook from a first using VBA

查看:37
本文介绍了使用VBA从第一个密码保护第二个工作簿的宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作簿,该工作簿创建了第二个工作簿(使用 ThisWorkbook.SaveCopyAs )以将数据很好地呈现给用户.它依赖宏进行部分处理.

I have a workbook, which creates a second workbook (using ThisWorkbook.SaveCopyAs) to present the data nicely to users. It relies on macros for part of the processing.

但是,有人要求我使用户无法访问这些宏.他们仍然需要运行它们,但是要查看/编辑它们,则需要输入密码.我可以弄清楚如何使用GUI(VBA编辑器->右键单击VBAProject-> VBAProject属性->保护,在框内打勾并输入密码),但是我还没有找到使用VBA的方法. Workbook.Protect 函数似乎可以锁定除 VBA以外的所有内容.

However, I've been asked to make those macros inaccessible to users. They still need to run them, but to view/edit them should require a password. I can figure out how to do it using the GUI (VBA Editor -> right click VBAProject -> VBAProject Properties -> Protection, tick the box and enter a password), but I haven't found a way to do so using VBA. The Workbook.Protect function seems to lock down everything except VBA.

如果我尝试将其应用于源工作簿,则会收到由于项目受保护而无法执行操作"的消息,因此也不起作用.

If I try to apply it to the source workbook, I get "Can't perform operation since the project is protected", so that doesn't work either.

我正在运行2010,但是工作簿需要与2003兼容,因此没有新奇的花样.:(

I'm running 2010, but the workbook needs to be compatible with 2003, so no fancy new tricks. :(

推荐答案

这是描述不使用sendkeys来设置项目密码的方法

This is a method that describes setting the project password without using sendkeys http://www.standards.com/Office/SetVBAProjectPassword.html

这篇关于使用VBA从第一个密码保护第二个工作簿的宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆