【发布时间】:2010-12-15 07:49:06
【问题描述】:
我在 PHP 中使用 COM 在 Windows server 2003 中成功操作 MS Word 2003,但相同的代码在 Windows 2008 server 中被破坏。我已将用户更改为管理员,但仍然出现同样的错误。
下面的代码:
<?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("C:\\wamp\\www\\iword\\Useless test.doc");
//closing word
$word->Quit();
//free the object
$word = null;
?>
我收到了这个错误:
加载的 Word,版本 11.0 致命错误:C:\wamp\www\iword\index.php 中的消息“来源: Microsoft Word
描述: 命令失败”未捕获的异常“com_exception” :14 堆栈跟踪:#0 C:\wamp\www\iword\index.php(14): variant->SaveAs('C:\wamp\www\iwo...') #1 {main} 在 C 中抛出:\wamp\www\iword\index.php 第 14 行
【问题讨论】: