COM giving me access denied message
Posted: Wed Mar 16, 2011 7:30 pm
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...
and I keep getting this error...
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";
?>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 advanceFatal 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