View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Spell Checking a String

Robert,

Try the macro below, which requires that the activesheet not be protected.

HTH,
Bernie
MS Excel MVP

Sub Macro1()
CheckMySpelling Application.InputBox( _
"Give me an input that might be misspelled")
End Sub

Sub CheckMySpelling(strTestWrong As String)
Dim strTestCorrect As String
Dim myWords As Variant
Dim i As Integer
Dim myCell As Range

myWords = Split(strTestWrong, " ")
For i = LBound(myWords) To UBound(myWords)
If Not Application.CheckSpelling(myWords(i)) Then
GoTo CorrectSpelling
End If
Next i
MsgBox """" & strTestWrong & """ was correctly spelled."
Exit Sub

CorrectSpelling:

Application.ScreenUpdating = False
Set myCell = Range("A65536").End(xlUp)(2)
myCell.Value = strTestWrong
myCell.CheckSpelling
strTestCorrect = myCell.Value
myCell.Clear
MsgBox strTestWrong & Chr(10) & "was corrected to be " & _
Chr(10) & strTestCorrect
Application.ScreenUpdating = True

End Sub


"Robert Mulroney" '''' wrote in message
...

I'd like to be able to spell check the text a user has entered in a RTF-Text
box within an excel form. If I was working in MS-Word I would just use the
getSpellingSuggestions() function to check each word in the RTFTextbox.Text
string.

Unfortunately I can't even create a Word application object

ie. CreateObject("Word.Application")

because the system doesn't have Word installed on it, only Excel. Does Excel
have a similar function in it, or is there some other office library I can
import that does?

- Rm