COM giving me access denied message

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
danwguy
Forum Contributor
Posts: 256
Joined: Wed Nov 17, 2010 1:09 pm
Location: San Diego, CA

COM giving me access denied message

Post by danwguy »

I am trying to run a pretty simple script to learn about COM and things of that nature, running IIS and php5 something. All my php scripts work, and I found a fix that said launch dcomcnf and change Microsoft Word 2007 from the launching user to the interactive user and still get error. Here is my script...

Code: Select all

<?php
$word = new COM('word.Application') or die('Unable to load Word');
com_load_typelib('word.Application');
$empty = new VARIANT();
print "Loaded Word, version {$word->Version}\n";
$word->Documents->Open('C:/Unfilled.DOC');
$word->Selection->GoTo(wdGoToBookmark, $empty, $empty, 'Robert');
$word->Selection->TypeText($_GET['YourName']);
$word->Selection->GoTo(wdGoToBookmark, $empty, $empty, '30');
$word->Selection->TypeText($_GET['YourAge']);
$word->Documents[1]->SaveAs("C:/{$_GET['YourName']}.doc");
$word->Quit();
$word->Release();
$word = null;
print "Word closed. \n";

?>
and I keep getting this error...
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.Application': Access is denied. ' in C:\WEB_ROOT\wordtest.php:2 Stack trace: #0 C:\WEB_ROOT\wordtest.php(2): com->com('word.Applicatio...') #1 {main} thrown in C:\WEB_ROOT\wordtest.php on line 2
I have tried giving all the permissions I can think of in dcomcnfg but it just will not launch. Any help please? Thank you in advance
Post Reply