Word's built-in dictionary is not searchable, mainly because it
doesn't contain whole words in readable form. It contains word roots,
prefixes, suffixes, irregular forms, and coded rules for constructing
matches, finding synonyms, and so forth.
What you can do is put a random "word" into a document, run the
spellchecker on it, and see whether it suggests any corrections. You
can do this in a loop, continuing until you get a suggestion. The code
for this is below.
The real problem is that for security, passwords should never be
ordinary words taken from a dictionary. Such passwords are vulnerable
to a "dictionary attack" -- a hacker merely tries thousands of words
from his own dictionary, and eventually finds the one you used. If
random strings of characters are too hard to remember, you should
start with a word you can remember and replace some of its characters
with numbers, transpose some characters, and use odd combinations of
upper and lower case.
For instructional purposes, here's sample code for the dictionary
"search":
Sub SuggestWord()
Dim myRg As Range
Dim seed As String, pwd As String
Dim idx As Integer
Dim bDone As Boolean
Const CharList = "abcdefghijklmnopqrstuvwxyz"
Randomize
Set myRg = ActiveDocument.Range
With myRg
' separate seed from last word in doc
.Collapse wdCollapseEnd
.Text = " "
.Collapse wdCollapseEnd
bDone = False
Do While Not bDone
' create a random 8-char seed
seed = ""
For idx = 1 To 8
seed = seed & Mid(CharList, 26 * Rnd + 1, 1)
Next idx
' insert it at end of doc
.Text = seed
' see whether spellchecker suggests a "correction"
If .Words(1).GetSpellingSuggestions.Count <> 0 Then
pwd = .Words(1).GetSpellingSuggestions.Item(1).Name
' check whether length is 6 to 10 chars
If (5 < Len(pwd)) And (Len(pwd) < 11) Then
MsgBox pwd
bDone = True
End If
End If
Loop
' clean up -- delete myRg and preceding space
.Delete
ActiveDocument.Characters.Last.Previous.Delete
End With
End Sub