![]() |
#1
|
|||
|
|||
![]()
Hello All,
Very new to the entire world of VBA and Macros. I started with a want to add a random password generator to Word document. Some other people wanted the same thing and they were provided with some code that works exactly how I would like to it to. This being said, I would like the randomized string of characters to appear in a table titled 'Password' instead of the message box. The code I am using is: Code:
Sub PASSWORD_GENERATOR() MsgBox Pwd(8) End Sub Function Pwd(iLength As Integer) As String Dim i As Integer, iTemp As Integer, bOK As Boolean, strTemp As String '48-57 = 0 To 9, 65-90 = A To Z, 97-122 = a To z 'amend For other characters If required For i = 1 To iLength Do iTemp = Int((122 - 48 + 1) * Rnd + 48) Select Case iTemp Case 48 To 57, 65 To 90, 97 To 122: bOK = True Case Else: bOK = False End Select Loop Until bOK = True bOK = False strTemp = strTemp & Chr(iTemp) Next i Pwd = strTemp End Function As always - Any and all assistance is appreciated - Thank you Last edited by macropod; 05-02-2017 at 03:56 PM. Reason: Added code tags & formatting |
Tags |
msg box, table, vba in microsoft word |
|