VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Spell-check a Text box using MS Word's spellchecker.

by Joe Dacy II (6 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 3rd October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Spell-check a Text box using MS Word's spellchecker.

API Declarations


Global bSelected As Boolean


Rate Spell-check a Text box using MS Word's spellchecker.




Set objWord = CreateObject("Word.Basic")
objWord.FileNew
objWord.EditClear
' spell check only the selected text
If Text1.SelText <> "" Then
bSelected = True
objWord.Insert Text1.SelText
Else 'spell check all text in the box.
objWord.Insert Text1.Text
End If
objWord.StartOfDocument
objWord.EndOfDocument (1)
objWord.ToolsSpelling
objWord.StartOfDocument
objWord.EndOfDocument (1)
objWord.EditCut
With Text1
If bSelected Then
.Text = Left$(.Text, .SelStart) & Clipboard.GetText(1) & Right$(.Text, Len(.Text) - (.SelStart + .SelLength))
Else
.Text = Clipboard.GetText(1)
End If
' closes MS Word
objWord.FileClose (2)
.SetFocus
End With
objWord.FileQuit
Set objWord = Nothing
Text1.SetFocus
Exit Sub
ERRC:
Resume Next

' Note: large amounts of text will cause MS Word to ask if you want to save what's in the clipboard for later use.
' This works for Rich Text Boxes and in Word 2000.


Download this snippet    Add to My Saved Code

Spell-check a Text box using MS Word's spellchecker. Comments

No comments have been posted about Spell-check a Text box using MS Word's spellchecker.. Why not be the first to post a comment about Spell-check a Text box using MS Word's spellchecker..

Post your comment

Subject:
Message:
0/1000 characters