Copy the code The code is as follows:
// Create an index pointing to the new COM component
$word = new COM("word.application") or die("Can't start Word!");
// Display the version number of Word currently being used
//echo "Loading Word, v. {$word->Version}
”;
// Set its visibility to 0 (false). If you want it to open at the front, use 1 (true)
// to open the application in the forefront, use 1 (true)
//$word->Visible = 0;
//Open a document
$word->Documents ->OPen(”d:mywebmuban.doc”);
//Read document content
$test= $word->ActiveDocument->content->Text;
echo $test;
echo “
”;
//Replace the variables that need to be replaced in the document
$test=str_replace(”<{variable}>”, "This is a variable",$test);
echo $test;
$word->Documents->Add();
// Add text in a new document
$word- >Selection->TypeText(”$test”);
//Save the document in the directory
$word->Documents[1]->SaveAs(”d:/myweb/comtest. doc");
// Close the connection with the COM component
$word->Quit();
?>
http://www.bkjia.com/PHPjc/318933.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318933.htmlTechArticleCopy the code as follows: ? //Create an index pointing to the new COM component $word=newCOM(”word. application")ordie("Can'tstartWord!"); //Display the version number of Word currently in use...