Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA随机字模拟_Excel_Vba_Encryption_Random - Fatal编程技术网

Excel VBA随机字模拟

Excel VBA随机字模拟,excel,vba,encryption,random,Excel,Vba,Encryption,Random,我试图编写一些代码,用一个随机单词锁定当前工作表,该单词在每次使用宏时都会更改 到目前为止,我已经: Sub Protect() ' ' Protect Macro ' Dim strPassWord As String ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True strPassWord = "hello" End Sub 然而,这实际上并没有用密码“hell

我试图编写一些代码,用一个随机单词锁定当前工作表,该单词在每次使用宏时都会更改

到目前为止,我已经:

Sub Protect()
'
' Protect Macro
'
    Dim strPassWord As String
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    strPassWord = "hello"    
End Sub

然而,这实际上并没有用密码“hello”锁定电子表格,而只是锁定它,并通过单击“unprotect sheet”轻松解锁。我想推进这一点,不仅用“hello”来锁定它,而且用随机词来锁定它。

创建一个函数来生成随机“词”

所以你可以用

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:=RandomWord

现在,你他妈的为什么要用随机密码来保护工作表呢?

你怎么才能得到一个随机的单词?从列表中,随机字母?你的代码毫无意义!你的意思是
ActiveSheet.Protect DrawingObject:=True,Contents:=True,Scenarios:=True,Password:=“hello”
??是的,但“hello”只是一个例子。是的,最好是随机的字母。谢谢在如何生成随机单词方面有很多帮助。先试试他们,如果你有困难就回来寻求帮助。这是通常的做法。
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:=RandomWord