<?php
// 建立一个指向新COM组件的索引
$word = new COM("word.application") or die("Can't start Word!");
//打开一个文档
$word->Documents->OPen("F:/wamp/www/oa/111.doc");
//读取文档内容
$test= $word->ActiveDocument->content->Text;
echo $test;
echo "<br>";
//将文档中需要换的变量更换一下
$test=str_replace("<{变量}>","这是变量",$test);
echo $test;
$word->Documents->Add();
// 在新文档中添加文字
$word->Selection->TypeText("$test");
//把文档保存在目录中
$word->Documents[1]->SaveAs("F:\wamp\www\oa\111.doc");
// 关闭与COM组件之间的连接
$word->Quit(); ?>IE 浏览器下的错误报告
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': 尚未调用 CoInitialize。 ' in F:\wamp\www\oa\newfile.php:3 Stack trace: #0 F:\wamp\www\oa\newfile.php(3): com->com('word.applicatio...') #1 {main} thrown in F:\wamp\www\oa\newfile.php on line 3遨游下的错误报告
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': 尚未调用 CoInitialize。 ' in F:\wamp\www\oa\newfile.php:3 Stack trace: #0 F:\wamp\www\oa\newfile.php(3): com->com('word.applicatio...') #1 {main} thrown in F:\wamp\www\oa\newfile.php on line 3我求解释
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Word<br/><b>Description:</b> ��Ϊû�д