craete word doc using php script

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
samir2004
Forum Newbie
Posts: 1
Joined: Wed May 07, 2008 12:40 am

craete word doc using php script

Post by samir2004 »

Hi All,

can any one help me to creating word doc using php script.
Requirement

i have created Text editor. but what ever content we i can create in text editor it should save in word document.

i am sending php script to you.. this is static but i want to save dynamic contents.
<?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("text1.doc");

//closing word
$word->Quit();

//free the object
$word = null;
?>
please send code or Advice me on this is highly appreciated.

Regards,
Sam
Post Reply