【问题标题】:PHP COM failed on Windows 2008 ServerPHP COM 在 Windows 2008 服务器上失败
【发布时间】: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 行

【问题讨论】:

    标签: php com ms-word


    【解决方案1】:

    Apache 服务需要 1 个具有网络权限的窗口帐户才能启动它。很简单,你需要通过命令启动 apache 来测试。不要通过服务启动 apache。

    【讨论】:

      【解决方案2】:

      我猜我会说你有一个权限问题,你不能写入那个目录,我建议在 VBA 中尝试相同的代码来缩小可能的故障点。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-25
        • 1970-01-01
        • 2015-11-24
        • 1970-01-01
        • 2016-09-26
        • 1970-01-01
        • 1970-01-01
        • 2022-08-16
        相关资源
        最近更新 更多