Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fun with Word
Message
From
27/10/1999 10:40:56
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Fun with Word
Miscellaneous
Thread ID:
00282257
Message ID:
00282257
Views:
60
Hi All,

A question about the spellchecker in Word got me playing around with ways to spell check memo fields within VFP. I found a really neat way of doing it which I intend to put into a classlib for upload here, but here's the meat of the code for you "home hobbyists" out there:
oWord=CREATEOBJECT("Word.Application")     && Open Word
oWord.WindowState=2                        && Minimized
cSource="mytable.mymemofield"              && memo field
cContents=EVAL(cSource)                    && Get contents
_CLIPTEXT=""                               && Clear Clipboard
_CLIPTEXT=cContents                        && Set Clipboard to memo
oWord.Documents.Add.Content.Paste          && Paste into new word doc
oWord.ActiveDocument.CheckSpelling()       && Run spellchecker

** The following line is necessary because spell checking turns on 
** the Word window.  

oWord.Visible=.F.                          =oWord.ActiveDocument.Select               && Select all word text
cText=oWord.Selection.Text                 && Put it into a cvar
IF cText # cContents  && If changed
   REPLACE mytable.mymemofield WITH cText  && Replace old w/new
ENDIF
_CLIPTEXT=""                               && Clear Clipboard
oWord.Documents.Close(0)                   && Close new doc (no save)
oWord.Quit(0)                              && Close Word (no save)
See? Fun stuff. You can also try this for grammar by substituting CheckGrammar() for CheckSpelling.
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Next
Reply
Map
View

Click here to load this message in the networking platform