ant
May 29th, 2001, 11:19 AM
how do you spell check a rich text box?
|
Click to See Complete Forum and Search --> : Help! ant May 29th, 2001, 11:19 AM how do you spell check a rich text box? Johnny101 May 29th, 2001, 12:34 PM 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 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |