Search code examples
phpcomms-word

PHP and Word Document Creation Issue


Below is the code snippet I'm using but I get the error underneath when executing it and can't seem to figure it out, I'm using PHP 5.3.27, it all worked fine in PHP 4 which I'm upgrading from.

$vObjBookmark = $this->mWord->ActiveDocument->Bookmarks($pBookmarkName);
$vRange = $vObjBookmark->Range;
$vTable = $this->mWord->ActiveDocument->Tables->Add($vRange, $pRows+1, $pCols, 0, 2);
@$vTable->Borders->Shadow = TRUE;
$vTable->AllowAutoFit = 1;
$vTable->AutoFitBehavior(0);

@$vTable->Borders->Shadow = TRUE; is on line 436 which seems to throw the error.

Error being thrown:

Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft Word
Description: Command failed' in genworddoc_class.php:436
Stack trace:
#0 genworddoc_class.php(436): genWordDoc::addFormattedTable7()
#1 genworddoc_class.php(330): genWordDoc->addFormattedTable7('BULK_TABL...', 1, 5, Array, Array, Array)
#2 c_generate_correspondence.php(444): genWordDoc->addTableArrayObjectsToTemplate('BULK_TABL...', Array, Array, NULL, NULL, Array)
#3 main.php(190): include('C:\htdocs\...')
#4 index.php(6): include('C:\htdocs\...')
#5 {main} thrown in genworddoc_class.php on line 436

Solution

  • Found to be an issue with Word and the PHP script executing too fast for Word to respond.