关于php中的Com对象

时间:2012-05-30 08:26:41

标签: php shell com shellexecute

如何使用com对象创建功率点文件MS word文件。 请举一些例子。我尝试了几件事。但我在我的系统中找不到该文件

示例代码如下所示

$word = new COM("word.application") or die ("couldnt create an instance of word"); 
echo "loaded , word version{$word->version}"; 

$word->visible = 1; 

$word->Documents->Add(); 

$word->Selection->TypeText("this is some sample text in the document"); 

$word->Documents[1]->SaveAs("sampleword.doc"); 

$word->Quit(); 

$word->Release(); 
$word = null; 

1 个答案:

答案 0 :(得分:0)

尝试设置完整路径

$word->Documents[1]->SaveAs("C:\\Users\\UserNameHere\\MyDocuments\\sampleword.doc");