Dim strText As String
Dim lngSuggWord As Long
Dim lngStart As Long
Dim lngPos As Long
Dim blnDone As Boolean
Dim objWord As Word.Application
Dim objDoc As Document
Dim colSuggestions As SpellingSuggestions
Dim colSpellErrors As ProofreadingErrors
'
'---------------------------------------------
' Spell check the text.
'---------------------------------------------
'
On Error GoTo ErrorHandler
'
' Start and hide Word.
'
Set objWord = CreateObject("word.application"
objWord.Visible = False
objWord.WindowState = wdWindowStateMinimize
'
' Create a new Word document.
'
Set objDoc = objWord.Documents.Add
'
' Loop through the text.
'
blnDone = False
lngStart = 1
lngPos = 0
Do While Not blnDone
'
' Parse the text into words.
'
lngStart = lngPos + 1
lngPos = InStr(lngStart, txtText.Text, " "
If lngPos = 0 Then
lngPos = Len(txtText.Text) + 1
blnDone = True
End If
'
' Select a word.
'
txtText.SelStart = lngStart - 1
txtText.SelLength = lngPos - lngStart
If txtText.SelText <> "" Then
'
' Set the Word document's range to
' the selected text and call the
' spell checker.
'
objDoc.Range.Delete
objDoc.Range = txtText.SelText
Set colSpellErrors = objDoc.SpellingErrors
'
' If we have errors, get the suggestions.
'
If colSpellErrors.Count > 0 Then
With frmSpellCheck
.txtBadWord.Text = colSpellErrors.Item(1)
Set colSuggestions = objWord.GetSpellingSuggestions(colSpellErrors.Item(1))
.lstSuggestions.Clear
For lngSuggWord = 1 To colSuggestions.Count
.lstSuggestions.AddItem colSuggestions.Item(lngSuggWord)
Next
'
' Show the suggested word dialog.
'
.Show vbModal
'
' Swap the text taking into account the
' new word's length may differ.
'
If .ReplacementWord <> "" Then
txtText.SelText = .ReplacementWord
lngPos = lngPos + .LengthDifference
End If
End With
End If
End If
Loop
txtText.SelStart = 0
txtText.SelLength = 0
GoTo NormalExit
ErrorHandler:
MsgBox "The following error occured during the document's spelling" & vbCrLf & Err.Description
NormalExit:
'
' Close word and clean up.
'
objDoc.Close savechanges:=wdDoNotSaveChanges
objWord.Quit savechanges:=wdDoNotSaveChanges
Set objWord = Nothing
Set objDoc = Nothing
Using what I gave you for word, and this Microsoft Article I think you can certainly develop the functionality you require, or you can by the ready made product, either let me know what you think.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.