Page 1 of 1

Edit Word file(edit Fields in it) and save it thru PHP code

Posted: Fri Mar 27, 2009 3:47 pm
by tots581
I want to create new Word Template file which will have a field to put the Student name.
All other text, images will remain same except the student name.

Then I want to save the same file on the harddrive.

Please let me know how do I go ahead.

Thanks,
Dodo.

Re: Edit Word file(edit Fields in it) and save it thru PHP code

Posted: Sat Mar 28, 2009 12:22 am
by sujithtomy
Hello,

On windows you can use COM module.....

example:

Code: Select all

<?php
// starting word
$word = new COM("word.application") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}\n";
 
//bring it to front
$word->Visible = 1;
 
//open an empty document
$word->Documents->Add();
 
//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");
 
//closing word
$word->Quit();
 
//free the object
$word = null;
?>
more details on : http://in.php.net/manual/en/class.com.php