|
-
May 29th, 2001, 11:19 AM
#1
Help!
how do you spell check a rich text box?
-
May 29th, 2001, 12:34 PM
#2
Re: Help!
you can use a third party component or automate MS word. here's a sample:
private Function FN_SpellCheck(strTextToVerify as string) as Boolean
on error GoTo FN_SpellCheckErr
Dim oWord as Word.Application
Dim oDoc as Word.Document
Dim strSelection as string
set oWord = GetObject(, "Word.Application")
oWord.WindowState = wdWindowStateMinimize
set oDoc = oWord.Documents.Add
oDoc.Content.Select
' done immediately before to minimize possibility of user
' interaction with the clipboard
Clipboard.SetText strTextToVerify, vbCFRTF
oDoc.Range.Paste
oDoc.GoTo Which:=wdGoToFirst, what:=wdGoToLine
on error resume next
oDoc.CheckSpelling IgnoreUppercase:=true, AlwaysSuggest:=false
on error GoTo 0
oDoc.Content.Select
oDoc.Range.Copy
strSelection = Clipboard.GetText(vbCFRTF)
If mid(strSelection, len(strSelection), 1) = Chr(13) then
strSelection = mid(strSelection, 1, len(strSelection) - 1)
End If
If len(strSelection) > 1 then
strTextToVerify = strSelection
FN_SpellCheck = true
End If
oDoc.Close wdDoNotSaveChanges
set oDoc = nothing
set oWord = nothing
Exit Function
FN_SpellCheckErr:
MsgBox error
End Function
you can call it like this:
If FN_SpellCheck(Text1.Text) then
MsgBox "No errors"
else
MsgBox "Errors in document."
End If
hope that helps,
john
John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|