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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tots581
Forum Newbie
Posts: 1
Joined: Fri Mar 27, 2009 3:40 pm

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

Post 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.
sujithtomy
Forum Commoner
Posts: 46
Joined: Tue Mar 24, 2009 4:43 am

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

Post 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
Post Reply