Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning the contents of a Word document into a memo fi
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00121431
Message ID:
00121506
Vues:
17
>Hi John,
>
>Actually it is very easy. Simply copy the contents to the clipboard from word and the imformation will be available in _CLIPTEXT variable. You could then replace your memo contents with _CLIPTEXT.
>
>oWordObj = CREATE("Word.Application")
>....
>oWordObj.Selection.WholeStory
>oWordObj.Selection.Copy
>
>SELECT YourTable
>REPLACE YourField WITH _CLIPTEXT
>

>
>>It may be late and I'm just not thinking clearly, but I have appropriated the code from VFP 6's samples that show a form imbedding Word, placing some text in and formatting. That's great, but how do you take the contents of a memo field,send it to Word, let it spellcheck/grammar check and then (here's the biggie) return the changes to the memo field?


I sort of got it working, but the editbox control is screwy after running the Word session. It has the ghosted images of the text for each record. I would say it's a bug, except the beta is over and I won't get credit for it.< G >

I wound up using the following code. Could someone take a look and see if they can figure why it's messing up? Otherwise, I'll have to launch a seperate window with Word and pull the text back that way.

Code:
Form Init:
*
oForm = THISFORM
oForm.addobject('oWordDoc','olecontrol','word.document')
oForm.oWordDoc.Height = THISFORM.edit1.height
oForm.oWordDoc.Width = THISFORM.edit1.width
oForm.oWordDoc.Top = THISFORM.edit1.top
oForm.oWordDoc.Left = THISFORM.edit1.left
oForm.oWordDoc.object.content = THISFORM.edit1.value

EditBox Dblclick event of edit1 :
lWord97 = .T.
nMouseRow = MROW()
nMouseCol = MCOL()
oForm.oWordDoc.Visible = .t.
oForm.Show
oForm.oWordDoc.DoVerb(0)
IF TYPE("oForm.oWordDoc.object.name") # "C"
lWord97 = .F.
oWordRef = GetObject('','word.basic')
ENDIF
MOUSE CLICK AT 1,1
MOUSE AT m.nMouseRow,m.nMouseCol
IF m.lWord97
oForm.oWordDoc.object.content = THISFORM.edit1.value
ENDIF
thisform.isedited=.t.
THIS.ENABLED = .t.

Command button for updating the editbox - click event
if thisform.isedited
thisform.lockscreen=.t.
thisform.edit1.value=oForm.oWordDoc.object.content.text
thisform.isedited=.f.
thisform.refresh()
thisform.lockscreen=.f.
endif

I added a property to the form - isedited inits to .f. and there is a table called ads which has a memo field called bodytext. Bodytext is bound the controlsource for edit1. This is working fine, functionally, but the on screen results are unusable. If someone knows how to clear this up, I think this could be a very useful class for Word and Excel within a VFP Form.
John Harvey
Shelbynet.com

"I'm addicted to placebos. I could quit, but it wouldn't matter." Stephen Wright
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform