Uncaught исключение ‘com_exception’ с сообщением ‘& lt; b & gt; Источник: & lt; / b & gt; Microsoft Word & lt; b & gt; Описание: & lt; / b & gt; Команда не выполнена

После запуска скрипта у меня возникла проблема с моим скриптом непойманный
исключение ‘com_exception’ с сообщением ‘Источник: Microsoft Word Описание: Команда не выполнена’

и показать предупреждение:
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);
?>

1

Решение

Измените свой код на:

<?php
try{
$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);
}catch(Exception $e){
echo $e;
}
?>

Таким образом, это не остановит выполнение вашего кода, и вы сможете увидеть его в случае, если это произойдет. Обратите внимание, что идеальная вещь, чтобы сделать здесь, это заменить echo $e; с фактической обработкой ошибок.

1

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector