Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting a fields from one record into Word
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00449272
Message ID:
00450003
Views:
47
>Well, now Word gets launched, but this line says "member SELECTION does not evaluate to an object":
>oRange = oDocument.selection.range()
>
>I plan to pick up the book for the holidays :)
>
>Thanks.
>
Phil,

I don't think you need a range object here. Try the following:
oWord=CREATEOBJECT('word.application')
oDocument = oWord.documents.OPEN('c:\qcf19.doc')
oWord.VISIBLE=.T.
oSelection = oWord.Selection
#DEFINE wdLine 5

with oSelection
.MoveDown(wdLine,1)
.TypeParagraph
.TypeParagraph
.MoveUp(wdLine,2)
.InsertDateTime("MMMM d, yyyy",.f.)
.TypeParagraph
.Typeparagraph
.TypeText (l_address) && Macro expansion not necessary here
endwith
-Rick


>
>>Phil,
>>
>>PMFJI... Della is certainly the expert here, but I think you want the first line to be
oWord=CREATEOBJECT('word.application')
The application object contains the documents collection, which you can use to open a document as you're doing in your second line of code.
>>
>>BTW, Della and Tamar's "Office Automation" book is definitely a good investment if you're going to be doing much of this kind of work.
>>
>>-Rick
>>
>>>>Try this as the first four lines:
>>>>
<b>oWord</b>=CREATEOBJECT('word.document')
>>>><b>oDocument = oWord</b>.documents.OPEN('c:\qcf19.doc')
>>>><b>oWord</b>.VISIBLE=.T.
>>>>
>>>>oRange = <b>o</b>Document.selection.range()
>>>>
>>>>The bolding indicates changed items. Mostly, I've renamed the object variables to clarify what object is reference, though I did add an oDocument object so you can track the document separately.
>>>
>>>I took your advice, and now have the code shown:
>>>
>>>
oWord=CREATEOBJECT('word.document')
>>>oDocument = oWord.documents.OPEN('c:\qcf19.doc')
>>>oWord.VISIBLE=.T.
>>>oRange = oDocument.selection.range()
>>>#DEFINE wdLine 5
>>>
>>>with oRange
>>>.MoveDown(wdLine,1)
>>>.TypeParagraph
>>>.TypeParagraph
>>>.MoveUp(wdLine,2)
>>>.InsertDateTime("MMMM d, yyyy",.f.)
>>>.TypeParagraph
>>>.Typeparagraph
>>>.TypeText (&l_address)
>>>endwith
>>>
>>>I get an error on the second line (oDocument=oWord.documents.OPEN('c:\qcf19.doc') which says "Member DOCUMENTS does not evaluate to an object".
>>>
>>>(puzzled look)
>>>
>>>Thanks again for your patience and persistence :)
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform