Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word SpellChecker Example (Version 3)

COM and Automation

Word SpellChecker Example (Version 3)

by  jimoo  Posted    (Edited  )
Code to load Word and use Word's Spell Check and return the corrected results back to the form. It's pretty simple. I have used it in the past and it works very well.

This sample assumes the data is in an an edit box, but could easily be modified for any text item.

Step 1. Create a new form
Step 2. Add an edit box (by default edit1)
Step 3. Add a command button
Step 4. Place the following code in the click-event of the button:


IF EMPTY(ThisForm.Edit1.Value)
RETURN
ENDIF

oWord = CreateObject("word.application")

With oWord
.Documents.add
.Selection.TypeText(ThisForm.Edit1.Value)
.Visible = .T.
.Activedocument.CheckSpelling
.Selection.WholeStory
.Selection.Copy
.ActiveDocument.Close(0)

.Quit
EndWith

ThisForm.Edit1.Value = _ClipText

MESSAGEBOX("Spell Check Complete.")
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top