Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inserting a fields from one record into Word
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00449272
Message ID:
00449602
Vues:
15
>Think of the Selection object is your current place in the document. You can store this as a Range. A Range is also a place in the document, but it can be referenced again and again even if the Selection (current place) changes. You can have many Ranges in the document--only one Selection. Ranges are generally considered more efficient. So make it a Range object with:
>
oRange = oDocument.Selection.Range()
>Now use WITH oRange...ENDWITH around all those Selection lines, and delete "Selection" (leave the "." <s>).
>
>The Unit:=wdLine is a "named parameter." VFP doesn't support them, so you need to remove them <s>. Simply delete the parameter name and the := characters. Then properly format the method call by putting parentheses around the parameters. For example, that first line becomes:
>
WITH oRange
>  .MoveDown(wdLine, 1)
>  * other lines will go here
>ENDWITH
>
>That "wdLine" reference is a constant. These are built into VB/VBA, but we need to use #DEFINE to assign a value to it. In this case, wdLine has a value of 5. Where do you find the constants? I'll point you to a FAQ that Tamar Granor and I wrote for our book; the very last question has the answer on where to find the constants: http://www.hentzenwerke.com/catalog/autofoxfaq.htm
>
>Fix the InsertDateTime and TypeText methods the same way we fixed MoveDown. If you wind up with it squawking about wrong data types or a wrong number of parameters, chances are that the macro recorder listed them out of order. Look up the proper syntax in the VBA Word Help file; on my machine, it's at C:\Program Files\Microsoft Office\Office\1033\VBAWRD9.CHM. If it's not on your machine, you'll have to install it from the original Office CDs.

Della, thanks for taking the time to respond. I've hacked at it for awhile now and have this:
ox=CREATEOBJECT('word.document')
ox.APPLICATION.documents.OPEN('c:\qcf19.doc')
ox.APPLICATION.VISIBLE=.T.

oRange=Document.selection.range()  &&IT CHOKES HERE

#DEFINE wdLine 5

with oRange
.MoveDown(wdLine,1)
.TypeParagraph
.TypeParagraph
.MoveUp(wdLine,2)
.InsertDateTime("MMMM d, yyyy",.f.)
.TypeParagraph
.Typeparagraph
.TypeText (&l_address)
endwith
As a result of my misunderstanding of the Range object definition, nothing else works properly.
Phil Thomas
http://phillipdthomas.com

Never let your energy or enthusiasm be dampened by the discouragements that must inevitably come.....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform