1

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

2 Answers 2

1

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.

0

At a guess I would say you have a permissions issue where you cannot write to that directory, I would suggest trying the same code from within VBA to narrow down the likely points of failure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.