|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-02-28 15:58 UTC] fLAre_Dra_X at yahoo dot com
Description: ------------ I've download the version of PHP : http://snaps.php.net/win32/php5.0-win32-latest.zip It's work to call COM class, but when create object like word.application it failed. My configuration is disable all COM option on php.ini like com.allow_dcom. Is there any configuration that i need to do with my php or with my IIS ??? Reproduce code: --------------- <?php ini_set("com.allow_dcom","true"); // starting word $word = new COM("word.application") or die("Unable to instanciate Word"); print "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("Useless test.doc"); //closing word $word->Quit(); //free the object $word->Release(); $word = null; ?> Expected result: ---------------- Com object of word. Actual result: -------------- PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': Access is denied. ' in E:\Inetpub\wwwroot\tutor\com_word.php:4 Stack trace: #0 E:\Inetpub\wwwroot\tutor\com_word.php(4): com->com('word.applicatio...') #1 {main} thrown in E:\Inetpub\wwwroot\tutor\com_word.php on line 4 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 17:00:02 2025 UTC |
I am using windows 7 operating system, and i have the latest version of php as seen in xampp PHP/5.3.5. I tried to create a word document using COM but got the error below Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': Server execution failed ' in C:\xampp\htdocs\Snigdha_new1\Testing\testfile.php:33 Stack trace: #0 C:\xampp\htdocs\Snigdha_new1\Testing\testfile.php(33): com->com('word.applicatio...') #1 {main} thrown in C:\xampp\htdocs\Snigdha_new1\Testing\testfile.php on line 33 I used the as below // htmlviewer.php // convert a Word doc to an HTML file //$DocumentPath = str_replace("\\", "\\", $DocumentPath); $DocumentPath="../upload/gaurav_cv.rtf"; // create an instance of the Word application $word = new COM("word.application") or die("Unable to instantiate application object"); // creating an instance of the Word Document object $wordDocument = new COM("word.document") or die("Unable to instantiate document object"); $word->Visible = 0; // open up an empty document $wordDocument = $word->Documents->Open($DocumentPath); // create the filename for the HTML version $HTMLPath = substr_replace($DocumentPath, 'txt', -3, 3); // save the document as HTML $wordDocument=$word->Documents->SaveAs($HTMLPath, 3); // clean up $wordDocument = null; $word->Quit(); $word = null; // redirect the browser to the newly-created document header("Location:". $HTMLPath); header("Location:". $HTMLPath); ?> Can someone help