Replacing data in Word Doc MergeFields
Posted: Thu May 15, 2008 2:25 pm
Allow our users to hit a button on a page (done this part), which would allow them to save a word doc (doc is allready in the directory) and then print it, have the code to do this and it saves the doc on the client's machine, however when they press the button I need to get data from MySQL(know how to do this) in order to replace the Mergefields in the word doc, I have included a sample of the code and the word doc, can this be done without using the COM feature of MsWord,
any help would be greatly appreciated as I have no idea of the syntax to do this. Also I need to presevre the template to be used again, would this require saving the doc as a temp doc and sending the temp doc.
Running Unix, Apache web server and PHP 5.0
Code: Select all
<?
require_once 'REnewalFTCE.doc';
$lname = "Smith";
$fname = "John";
$frstlstname = "John Smith";
header("Content-Type: application/msword");
header('Content-Disposition: attachment; filename="REnewalFTCE.doc"');
?>Code: Select all
Partial Contents of word doc
school of Medicine
Faculty Agreement 2007-2008
Letter of Renewal
«TENURE», Clinician Educator Category
«FacultyName», «DEGREE»
Department of «DEPARTMENT»
Dear Dr. «LNAME»: