Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Eric den Doop
  Where is Eric den Doop?
 Houten
 Netherlands
 Eric den Doop
 To: emily
  Where is emily?
 ST
 Philippines
 emily
 Tags
Subject: RE: migrate/print formatted text in word
Thread ID: 415 Message ID: 462 # Views: 3 # Ratings: 0
Version: Unknown Category: General VFP Topics
Date: Thursday, May 31, 2001 1:42:51 AM         
   


> Hello Sir Eric,
>
> i don't quite understand your solution.
>
> what i have tried so far is to insert the word field and good thing is the formatted text is displayed correctly. so since it's a word field does this mean that this will only work if i use a template, ie a document wherein the fields are already in place?
>
> cos unfortunately i cannot use a template. the data is grouped and the number of records per group varies. the document is not a one record/page format.
>
> which is why the "do your usual stuff" in my SCAN...ENDSCAN routine is actually dumping/copying the contents to the document record by record. i'm not opening an existing document and use the cursor as a data source as done in mail merge. i'm creating the document from scratch and write the contents of the document line by line.
>
> i hope i make sense. and please bear with me... this is important.
> if using a template is the only way to achieve this then please say so... so i could... give up the idea?? :(
>
> emily

Hi Emily,

Line by line huh? No Template? Does not matter. Take a look at this:
#DEFINE wdFieldEmpty -1
loWord = CREATEOBJECT("Word.Application")
loWord.documents.add
scan
* do your usual stuff
* if you need an empty line, insert one now
STRTOFILE(yourrtfmemo, "d:\temp\rtf.rtf")
loWord.selection.fields.add(loWord.selection.range, wdFieldEmpty, [INCLUDETEXT "d:\\temp\\rtf.rtf"], .T.)
* insert page break?
endscan
loWord.visible = .T.

Note the use of the double \. If you use a single, then Word can not find the rtf.rtf file. You can quick and dirty convert a path with single \ to double \\ with the STRTRAN() function:
lcPath = "d:\temp\rtf.rtf"
lcPath = STRTRAN(lcPath, "\", "\\")

Hth
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts

ENTIRE THREAD

migrate/print formatted text in word Posted by emily d @ 5/28/2001 9:49:05 PM
RE: migrate/print formatted text in word Posted by Eric den Doop @ 5/29/2001 12:30:25 AM
RE: migrate/print formatted text in word Posted by emily d @ 5/30/2001 7:16:50 PM
RE: migrate/print formatted text in word Posted by Eric den Doop @ 5/31/2001 1:42:51 AM