php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32133 Failed create COM object
Submitted: 2005-02-28 15:58 UTC Modified: 2007-10-21 14:41 UTC
Votes:53
Avg. Score:3.8 ± 1.2
Reproduced:33 of 37 (89.2%)
Same Version:14 (42.4%)
Same OS:17 (51.5%)
From: fLAre_Dra_X at yahoo dot com Assigned:
Status: No Feedback Package: COM related
PHP Version: 5.0.1 OS: Windows XP SP 2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fLAre_Dra_X at yahoo dot com
New email:
PHP Version: OS:

 

 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-28 19:58 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-03-20 18:10 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2006-01-03 12:06 UTC] ozovadia at hotmail dot com
Installed the latest version (5.1.1.1) and still experiencing the same problem.
 [2006-01-03 13:31 UTC] ozovadia at hotmail dot com
Here is a possible solution:
Verify that the user has the appropriate permissions to start the DCOM server. 
1. In the Control Panel, double-click Administrative Tools, and then double-click Component Services. 
2. In the Component Services snap-in, expand Computers, expand My Computer, and double-click DCOM Config. 
3. In the right pane, locate the program you are trying to create. 
4. Right-click the program name, and then select Properties. On the Security tab, in the Launch and Activation Permissions group box, select Customize, and then click Edit.
5. Add the user (e.g. running the IIS server) to the permissions list, and give the user the appropriate permissions.

That should do it.
 [2007-11-06 12:32 UTC] taylor dot ren at gmail dot com
Acknowledged that the above solution works fine in Vista. 

But there is a new error message when I tried: 

$doc=$word->Documents->Add();

it says: 

Word is unable to trigger event. 

I have Office 2003 installed. I guess it is due to the Add method is not the corrrect method name. Any hints?
 [2008-04-25 22:52 UTC] webmaster at zeninmotion dot com
I had the same issue, solved it using this guide:

http://figured-it-out.com/figured-out.php?sid=24
 [2009-11-16 06:43 UTC] mic_sri at yahoo dot co dot in
hi

 i have the same problem. that is COM object is not create.
its run in my local server(WAMP).
In the remote server it is not run it shows  'Fail to create DOM object'

Please tell me any one where i made a mistake

Regards
Michael
mic_sri@yahoo.co.in
 [2011-11-17 10:15 UTC] pankaj dot raturi2911 at gmail dot com
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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC