Jump to content
Sign in to follow this  
Milton Cordova

Clave aleatoria

Recommended Posts

Hola este código genera una contraseña aleatoria y protege la hoja, pero debes tener en cuenta que es muy sencillo quitar la protección en excel por mas larga que sea la contraseña.

Sub GenPassword()
Dim Password As String
Dim x As Integer

For x = 1 To 85
If x Mod 2 = 0 Then
Password = Chr(Int((90 - 65 + 1) * Rnd + 65)) & Password
Else
Password = Int((9 * Rnd) + 1) & Password
End If
Next x

ActiveSheet.Protect Password
MsgBox "Hoja protegida, la contraseña de desbloqueo es: " & Password
End Sub
[/PHP]

Salu2

Share this post


Link to post
Share on other sites

Un poquito mas corto:

Function ContraseñaAleatoria() As String
ContraseñaAleatoria = 99999999 - CLng(Replace(Date, "/", "")) & _
99999999 - CLng(Replace(Time, ":", ""))
End Function
[/CODE]

Saludos a ambos

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  



×
×
  • Create New...

Important Information

Privacy Policy


CTA Templates.png