【发布时间】:2016-01-02 19:50:43
【问题描述】:
运行脚本后我的脚本出现问题 未捕获 带有消息“来源:Microsoft Word 描述:命令失败”的异常“com_exception”
并显示警报: http://imgur.com/HrDYrah
这是我的代码:
<?php
$word = new COM("Word.Application") or die ("Could not initialise Object.");
// set it to 1 to see the MS Word window (the actual opening of the document)
$word->Visible = 0;
// recommend to set to 0, disables alerts like "Do you want MS Word to be the default .. etc"
$word->DisplayAlerts = 0;
// open the word 2007-2013 document
$word->Documents->Open('C:\xampp\htdocs\Open_Office\test_4sk.docx');
// save it as word 2003
$word->ActiveDocument->SaveAs('C:\xampp\htdocs\Open_Office\newdocument.doc');
// convert word 2007-2013 to PDF
$word->ActiveDocument->ExportAsFixedFormat("C:\\xampp\htdocs\Open_Office\Main_PDF.pdf", 17, false, 0, 0, 0, 0, 7, true, true, 2, true, true, false);
// quit the Word process
$word->Quit(false);
// clean up
unset($word);
?>
【问题讨论】:
-
你试过用 try..catch 包围你的代码吗?把
try{放在一切之前,把}catch(Exception $e){ echo $e; }放在一切之后。 -
这个comment 可能就是你要找的。span>
-
subhanallah 这就是答案谢谢@FirstOne
标签: php com ms-word office-interop