创建屏蔽密码的对话框在 Word 中,您可以使用文本框创建自定义对话框,为用户提供信息。一般情况下,当在文本框中键入文本时,该文本按您键入的方式显示。然而,您可以使用 Visual Basic Edition UserForm 的属性来创建隐藏和屏蔽文本框效果。在创建密码对话框(不希望显示在文本框中所键入的文本)时,这很有用。要对此进行测试,请遵循如下操作: 创建对话框
键入字母时,不会显示键入的字母,而显示此星号。 检索文本的代码示例 要检索写入此文本框中的文本字符串,可以使用以下示例代码:
取消/重设文档保护以下过程取消或重设文档保护: Sub ProtectIt(ProtectType) If ProtectType <> wdNoProtection Then If ActiveDocument.ProtectionType = wdNoProtection Then ActiveDocument.Protect Type:=ProtectType, NoReset:=True, Password:="My_PassWord" End If End If End Sub Function UnprotectIt() wasLocked = ActiveDocument.ProtectionType If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect "My_Password" End If UnprotectIt = wasLocked End Function 要在代码段中使用它,请尝试以下操作: ' First unprotect the document. ProType = UnprotectIt() ' Here goes the code to be done in the unprotected document ' then lock it back up. ProtectIt ProType 小结本文介绍了在 Word 中使用的一些技巧和 VBA代码。通过使用这些步骤并根据需要进行修改,可以使您的应用程序更加可靠,并为您的用户提供更多的选择。 (责任编辑:admin) |