>>Good Morning,
>>
>>I am using Automation to launch Word so that the user can generate a vendor survey form:
>>
>>
ox=CREATEOBJECT('word.document')
>>ox.APPLICATION.documents.OPEN('c:\qcf19.doc')
>>ox.APPLICATION.VISIBLE=.T.
>>
>>I'd like to be able to insert the vendor name, address, etc for the current record into Word programatically - can this be done?
>
>
>Sure it can be done! Try something like this:
>
>oWord = CreateObject('Word.Document')
>oWord.Visible = .T.
>oDocument = oWord.Documents.Add()
>
>* Grab a reference to the document range:
>oRange = oDocument.Range()
>
>* Create your text string
>* cText = cMyvar + " " + cMyVar2 + CHR(13)
>* Use CHR(13) to insert a paragraph return
>
>* Insesrt the text string.
>oRange.InsertAfter(cText)
>
>A good way to figure out what you want to do is to fire up Word and run through the steps interactively while recording a macro. Wherever the data goes, simply use your field name as the text. When done, stop the macro and examine it in the VBEditor (I use Alt-F11 to get there quickly, but I think it's under Tools | Macros | VBEditor). Open the Module, and you'll find some VB code. It's not too hard to translate to VFP <s>. There's a good KB article on how to do that at
http://support.microsoft.com/support/kb/articles/Q160/0/64.asp (KB article #Q160064 if the link doesn't work).
>
>Hope this helps!
>
> - della
Della,
Let me be more specific. I want to open Word with a pre-typed letter in it (the two page survey) and simply insert the address information from the current VFP record at the top. (as I understand your example, it is creating a new document). I'll try to show my "concept" below:
****************************************************************
cName
cAddr1
cAddr2
cCity, cState, cZipThis is the beginning of the pre-existing letter, which is two pages in length...and it never changes..............
***************************************************************
Thanks,
Phil Thomas
http://phillipdthomas.comNever let your energy or enthusiasm be dampened by the discouragements that must inevitably come.....