Word 2007 单个单词的密码保护
是否可以为word文档中的单个单词设置密码?
我想要的是根据我们的IT结构编写一个系统文档。我也想将密码放在文档中。现在我希望您必须输入“主”密码才能解锁文档内的密码。如果不输入密码,文档中的密码应该是不可见的或类似的。
这可能吗?
is it possible to put a password on a single word inside a word document?
What I want is to write a system documentation from our IT structure. I want to put the passwords in the document as well. Now I want that you have to enter a "MASTER" password in order to unlock to passwords inside the document. If you do not enter the password, the passwords inside the document should be invisible or something like that.
Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是可能的。为了完成这项工作,我们必须结合使用 Word 固有的文档保护、隐藏文本属性和一些 VBA 技巧。
首先,将文档中的所有密码格式化为隐藏文本。 (对于那些不熟悉的人来说,只有当“显示/隐藏”功能设置为 true 时,隐藏文本才可见。)
然后添加代码以确保隐藏文本不会显示,并在文档打开时保护文档不被编辑。打开:
因为Word用户通常可以在任何给定时间显示隐藏文本,所以我们也需要控制此功能。大多数菜单和功能区命令可以通过创建一个包含以拦截命令命名的子例程的模块来拦截。命名子
ShowAll
将允许我们控制此功能,并且仅在输入密码时显示隐藏文本:最后,我们添加一些代码来提示用户输入密码,如果输入正确,则显示以前隐藏的文本:
输入所有 VBA 代码后,右键单击 IDE 中的模块,选择项目属性,然后在“保护”选项卡上分配单独的密码。这将阻止高级用户获取嵌入的密码或更改代码。
剩下要做的就是在 Word 中创建一个 QAT 按钮(仅对此文档可见)并为其分配
RemoveProtection
子项。每当打开文档时,密码都会被隐藏并防止编辑,但可以通过单击 QAT 按钮并输入正确的密码来显示。编辑
当我第一次回答这个问题时,我没有考虑到Word有一个隐藏文本选项,可以与“全部显示”选项分开打开。此外,可以通过打印选项打印隐藏文本。我在上面的
AddProtection
中添加了代码来关闭这些设置。进一步测试还表明,Word 2007 中的用户可以手动进入 Office Orb|选项|显示,通过更改显示所有格式标记 或 显示隐藏文本手动隐藏文本选项。为了避免这种情况,需要创建功能区自定义并将其与文档一起加载。
最后,值得注意的是,虽然让 Word 随心所欲地完成这样的任务很有趣,但保护程度不如单独加密密码,然后在泄露内容之前解密,甚至使用Word的文档密码功能对文档的全部内容进行加密。
Yes, this is possible. To make this work we have to use a combination of Word's inherent document protection, its hidden text attribute, and a couple of VBA tricks.
First, format all the passwords in the document as hidden text. (For those who are unfamiliar, hidden text is only visible when the Show/Hide function is set to true.)
Then add code to make sure that the hidden text will not display and also to protect the document from being edited whenever the document is opened:
Because Word users can normally display hidden text at any given time, we also need to take control of this function. Most menu and Ribbon commands can be intercepted by creating a module containing subroutines named for the intercepted commands. Naming a Sub
ShowAll
will allow us to control this function and only display hidden text when a password is entered:Finally, we add some code to prompt the user for a password and, if entered correctly, display the text that was formerly hidden:
Once all the VBA code is entered, right-click on the module in the IDE, select Project Properties, and assign a separate password on the Protection tab. This will stop power users from getting to the embedded password or changing the code.
All that's left to do is create a QAT button in Word (that is only visible for this document) and assign the
RemoveProtection
sub to it. Whenever the document is opened the passwords will be hidden and protected from editing, but can then be revealed by clicking on the QAT button and entering the correct password.EDIT
When I first answered this question, I failed to consider that Word has a hidden text option that can be turned on separateley from the Show All option. Additionally, hidden text can be printed via a printing option. I have added code in
AddProtection
above to turn off these settings.Further testing also revealed that a user in Word 2007 could manually go into Office Orb|Options|Display to reveal the hidden text by changing the Show all formatting marks or Hidden text options manually. To avoid this, a Ribbon customization would need to be created and loaded with the document.
Finally, it is worth noting that although it is great fun to bend Word to one's will in order to make it accomplish tasks like this, the level of protection is not as good as encrypting the passwords separately and then unecrypting before revealing the contents or even using Word's document password feature to encrypt the document's entire contents.