PHP COM failed on Windows 2008 Server

comms-wordPHP

I use COM in PHP to manipulate MS Word 2003 with success in Windows server 2003, but the same code are broken in Windows 2008 server. I've changed the user to administrator but still the same error occurred.

For the code below:

<?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;
?>

I got this error:

Loaded Word, version 11.0
Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft Word
Description: Command failed' in C:\wamp\www\iword\index.php:14 Stack trace: #0 C:\wamp\www\iword\index.php(14): variant->SaveAs('C:\wamp\www\iwo…') #1 {main} thrown in C:\wamp\www\iword\index.php on line 14

Best Answer

Apache services need 1 window account have permission network to start it. Simple you need start apache via command to test. Don't start apache via services.