Mickwj Level: Guest

|
Re: Spell Checking Archived to Disk
Hey there
Here is some code I found a while ago. It requires that you have MS Word on the pc. In your project, under References, make sure that Microsoft Word 9.0 Object library is selected.
Next create on a new form, one textbox, three buttons (you will see from the code what to call them) , and a list box.
Option Explicit
Dim MSWord As Word.Application
Private Sub cmdCheck_Click()
Dim strText As String
Dim Suggestion As Word.SpellingSuggestion
Dim colSuggestions As word.SpellingSuggestions
If MSWord.Documents.Count = 0 Then MSWord.Documents.Add
strText = Trim$(txtWord.Text)
lstSuggestions.Clear
If MSWord.CheckSpelling(strText) Then
lstSuggestions.AddItem "(Correct)"
Else
Set colSuggestions = MSWord.GetSpellingSuggestions(strText)
If colSuggestions.Count = 0 Then
lstSuggestions.AddItem "(No Suggestions)"
Else
For Each Suggestion In colSuggestions
lstSuggestions.AddItem Suggestion.Name
Next
End If
End If
End Sub
Private Sub cmdClear_Click()
txtWord.Text = ""
lstSuggestions.Clear
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub Form_Load()
Set MSWord = New Word.Application
End Sub
|