调用 CoInitialize() 的语法;来自 PHP?
我正在尝试组装一个服务器,将 HTML 转换为本机 Word 文档。它可以工作,但有时我会收到以下错误:
Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': CoInitialize has not been called.
我使用的是 PHP,而不是 ASP 或更多 Microsoft-y 的东西,因为它应该只是一个快速项目。
我像这样初始化一个 COM 对象:
$word = new COM("word.application") or die("Unable to instantiate Word");
谁能告诉我如何从 PHP 调用 CoInitialize() ?
非常感谢
I'm trying to hack together a server that turns HTML into native Word docs. It works, but some of the time I get the following error:
Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': CoInitialize has not been called.
I'm using PHP and not ASP or something more Microsoft-y because it is supposed to just be a quick project.
I initialize a COM object like this:
$word = new COM("word.application") or die("Unable to instantiate Word");
Could anyone tell me how I can call CoInitialize() from PHP?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查并确保您没有任何 WINWORD.EXE 的恶意副本。我遇到了这个错误,当我检查时,我有 36 个 WINWORD.EXE 副本正在运行。我显然错过了与 COM 对象断开连接的一些逻辑,因此每次重新加载脚本时,现有的 WINWORD 都会陷入困境,而新的 WINWORD 会启动。一旦我删除了所有的 WINWORD,错误就消失了。
Check to make sure you don't have any rogue copies of WINWORD.EXE hanging around. I ran into this error, and when I checked, I had 36 copies of WINWORD.EXE running. I had apparently missed some logic in disconnecting from the COM object, so every time I reloaded the script, the existing WINWORD was left in limbo while a new one launched. Once I nuked all the WINWORDs, the error went away.