2009-11-11 4 views
1

J'utilise COM en PHP pour manipuler MS Word 2003 avec succès dans Windows Server 2003, mais le même code est cassé dans le serveur Windows 2008. J'ai changé l'utilisateur en administrateur mais la même erreur s'est produite.PHP COM a échoué sur Windows 2008 Server

Pour le code ci-dessous:

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

J'ai eu cette erreur:

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

Répondre

0

A une supposition, je dirais que vous avez un problème d'autorisations où vous ne pouvez pas écrire dans ce répertoire, je suggère essayer le même code à l'intérieur de VBA pour affiner les points probables d'échec.

1

Les services Apache ont besoin d'un compte de fenêtre pour avoir le droit de le démarrer. Simple, vous devez démarrer Apache via la commande pour tester. Ne démarrez pas Apache via des services.

Questions connexes