Today the word 2007 first introducing SaveAs in PDF format is over 10 years old, so I'm pretty sure this output option is available with Word automation, too (as in my sample code fileformat 17). If this is a feature starting from scratch I'd also consider a report solution, as a report is the straight forward way to put data on paper or into PDFs.īut if a word template exists. Presumable, because the Word template already exists. RE: pass data from foxpro to word document. Otherwise, you have been pointed to the automation help chapter, there are whole books on the subject from Hentzenwerke, too.
Overall, if you do that in a loop over your data with SCAN.ENDSCAN you've done nothing less than programmed a specific mailmerge with own means, this is mainly what mail merge does, load data, for each row do a series of placement of data fields into the mail merge template and save that. Perhaps post the code you end up and we may help with the translation. The VFP loWord object is the Application object in VBA code and loDocument is ActiveDocument. Never just put in pure file names, Word is a separate process, it doesn't act on VFPs or your applications working directory or DEFAULT/CD path.ģ. Replace folders of templates and voucher output. Replace the filename of the template Voucher.dotx, this may also be a docx or dot or doc, doesn't matter.Ģ. Advantage: If you put in such placeholders mutliple times it's still just one search&replace per data field you want to fill in.ġ. Let me make the assumption you have a doc file where name and date were filled in manually and you have _ within a text for that, then perhaps rather replace that with something unique like $customername$, $bookingdatebegin$, $bookingdateend$, so a search and replace can find these unique placeholders and not replace anything else in the text.
Now, just don't set the text cursor at the place to write to and manually write something, that macro recording would be quite useless, record a search&replace. You may even record opening the document and saving it as whatever filetype you want and get the necessary fileformat constant (here using 17 for PDF), at least the constant name you then may lookup here. LoDocument.SaveAs("C:\Vouchers\xyz.pdf",17) LoDocument = ("C:\WordTemplates\Voucher.dotx") LoWord = CreateObject("Word.Application")