Using MS Main Library in Access VBA

S

Stuart Henry

I am trying to build an anagram utility for improving Scrabble skills. It
involves inputting seven letters and then creating a table with all possible
combinations for those seven letters (I have been able to do this pretty
easily). I next want to check that table against a dictionary to find out if
any of the combinations are actually words. Then I would like to write the
actual words to another table. I don't see how to use the Microsoft main
dictionary for this. It looks like I have to create my own custom
dictionary, but I don't know how I would populate that with all the words in
the English language. Is there a way to use the Microsoft main dictionary
for this purpose? Or does anyone else have any ideas?
 
M

Marshall Barton

Stuart said:
I am trying to build an anagram utility for improving Scrabble skills. It
involves inputting seven letters and then creating a table with all possible
combinations for those seven letters (I have been able to do this pretty
easily). I next want to check that table against a dictionary to find out if
any of the combinations are actually words. Then I would like to write the
actual words to another table. I don't see how to use the Microsoft main
dictionary for this. It looks like I have to create my own custom
dictionary, but I don't know how I would populate that with all the words in
the English language. Is there a way to use the Microsoft main dictionary
for this purpose? Or does anyone else have any ideas?


The Access "dictionary" is just the spell checking feature
that's part of all the Office applications. One way to get
to that is to place a string of characters in a textbox,
give it the focus, select all the characters, then use
DoCmd.Runcommand acCmdSpelling. That may cause problems in
that you will get the spell check dialog box.

You would probably be better off doing this project in Word
where you can use the CheckSpelling method. Or you may want
to explore using the Word Library or Automation to use that
function from Access.
 
D

Douglas J. Steele

Marshall Barton said:
The Access "dictionary" is just the spell checking feature
that's part of all the Office applications. One way to get
to that is to place a string of characters in a textbox,
give it the focus, select all the characters, then use
DoCmd.Runcommand acCmdSpelling. That may cause problems in
that you will get the spell check dialog box.

You would probably be better off doing this project in Word
where you can use the CheckSpelling method. Or you may want
to explore using the Word Library or Automation to use that
function from Access.

Function WordSpellCheck(WordToCheck As String) As Boolean
On Error GoTo Err_WordSpellCheck

Dim wd As Object

If Len(WordToCheck) > 0 Then
Set wd = CreateObject("Word.Application")
WordSpellCheck = wd.CheckSpelling(WordToCheck)
End If

End_WordSpellCheck:
If Not wd Is Nothing Then
wd.Quit
Set wd = Nothing
End If
Exit Function

Err_WordSpellCheck:
MsgBox Err.Description
Resume End_WordSpellCheck

End Function


Of course, to check a bunch of words, it would probably be better to
instantiate Word as a module-level object, rather than in the function.
 
M

Marshall Barton

Douglas said:
Function WordSpellCheck(WordToCheck As String) As Boolean
On Error GoTo Err_WordSpellCheck

Dim wd As Object

If Len(WordToCheck) > 0 Then
Set wd = CreateObject("Word.Application")
WordSpellCheck = wd.CheckSpelling(WordToCheck)
End If

End_WordSpellCheck:
If Not wd Is Nothing Then
wd.Quit
Set wd = Nothing
End If
Exit Function

Err_WordSpellCheck:
MsgBox Err.Description
Resume End_WordSpellCheck
End Function

Of course, to check a bunch of words, it would probably be better to
instantiate Word as a module-level object, rather than in the function.


Now, that's what I'm talking about!

Nice one Doug
 
Top