Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fun with Word
Message
De
27/10/1999 10:46:56
 
 
À
27/10/1999 10:40:56
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Divers
Thread ID:
00282257
Message ID:
00282258
Vues:
28
Yikes, watch out. The HTML parser didn't put oWord.ActiveDocument.Select on it's own line.


>
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform