Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Merging Different Documents in Word
Message
From
07/03/2006 12:56:36
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01101747
Message ID:
01102129
Views:
21
>Thanks for replying Tamar, I have what you have just suggested,
> I'm using a dbf as my data source, the first column in it stores the name of the template that should be merged with the data for that record, I just can't figure out how to instruct word to LOOP through all the records, open the template for that record and merge the data in that record
>with the template, If you can guide me in the right direction I will apreciate it, right now I can only see a solucion with VB for applications or macro which i'm not familiar with.
>

Something along these lines. Note this is untested:
* Assume oWord contains object reference to Word
SELECT DataToMerge
SCAN

  oWord.Documents.Open(DataToMerge.Template)
  oDoc = oWord.ActiveDocument

  * Set up merge data
  iKey = DataToMerge.iPK
  SELECT * ;
     FROM DataToMerge ;
     WHERE iPK = iKey ;
     INTO CURSOR OneRecToMerge

  * Put merge data into Excel file for merge
  cXLFile = FORCEPATH("MergeData.XLS",SYS(2023))
  COPY TO MergeData TYPE XL5

  * Attach to Document
  oDoc.MailMerge.OpenDataSource(cXLFile)

  * Merge
  oDoc.MailMerge.Execute

  * Now do something with the new document
  oWord.ActiveDocument.PrintOut()

  * Clean up
  oWord.ActiveDocument.Close(0)
  oDoc.Close(0)
ENDSCAN
Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform