PHP에서 COM을 사용하여 Windows Server 2003에서 MS Word 2003을 성공적으로 조작했지만 Windows 2008 서버에서 동일한 코드가 손상되었습니다. 사용자를 관리자로 변경했지만 여전히 동일한 오류가 발생했습니다. 아래의 코드를 Windows 2008 Server에서 PHP COM이 실패했습니다
:<?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;
?>
나는이 오류가있어 : 나는 당신이 그 디렉토리에 쓸 수있는 권한 문제를 가지고 말을 추측에
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