Just to sum up the permissions I had to set in DCOMCNFG I have written a short
text on the subject. I am posting it here in case others need it for reference.
Since the server does not accept mails larger than 40kb I am unable to post the
Word document with snapshots of the dialogs. I hope the text alone will suffice
though.
Best regards,
Mats Bjerin
--- Here we go ---
I have been experimenting for a couple of days using the COM object to call
functions inside Word 2000. I was constantly receiving an error about a �NULL
pointer exception� when trying to instantiate the Word object using the line:
$oWord = new COM("Word.Application") or die("Unable to instantiate Word");
taken from the example application kindly provided by Alain M. Samoun.
I am running Windows 2000 SP2, PHP 4.0.6 under IIS V5.
By reading through the forums on the PHPBuilder site I finally found a reference
to the application DCOMCNFG.EXE, which sets permissions for COM and DCOM
objects, under Windows. This was to be my �salvation�.
Others seem to receive the following message indicating the same problem under
different versions of PHP:
Warning: Unable to obtain IDispatch interface for CLSID
> {000209FF-0000-0000-C000-000000000046}: Access is denied. in
> C:\Inetpub\wwwroot\website\excel\word.php on line 3
> Unable to instantiate Word
Many thanks to the following people who through their discussions and advice to
each other solved my problem:
Alan Brown <[EMAIL PROTECTED]>
Mize, Robert <[EMAIL PROTECTED]>
To make Alain�s program work fully on my server the following conditions applied
at the time of my successful tests:
� I have IIS5 installed.
� I have Office 2000 SR-1 installed (obviously with Word 2000 i.e. V9) on the
server (the client installation of Word has nothing to do with the PHP-script
executing on the server).
� I have run the program DCOMCNFG.EXE and have changed the following permissions
for the Microsoft Document object from their default settings:
- Custom Access Permissions: �Allow� the �IUSR_<servername>� user access to the
object.
- The user account to run the application: �The interactive user�
� I am using Alain�s script (my version is displayed at the end of this document
for reference) installed in the wwwroot directory on the server.
For reference I am including my copy of Alain�s program:
<?php
$sNL = "<BR>\n";
print "Hello wor(l)d!{$sNL}";
#Instantiate the Word component.
$oWord = new COM("Word.Application") or die("Unable to instantiate Word!");
#Get and print its version.
print "Loaded Word, version {$oWord->Version}{$sNL}";
#Another way to get the version using com_get.
$testversion = com_get($oWord->application,version);
print "Version using Com_get(): $testversion {$sNL}";
#Make it visible in a window.
$oWord->Visible = 1;
#Open a new document.
$oWord->Documents->Add();
#Write something.
$oWord->Selection->TypeText("This is a test...");
#Now save the document.
$oWord->Documents[1]->SaveAs("Useless test.doc");
#Comment next line if you want to see the word document,
#then close word manually.
$oWord->Quit();
print "Finished.{$sNL}";
?>
--- End of document ---
Robert Mize wrote:
> After changing the permissions using dcomcnfg.exe, it is working. I never
> knew that existed.. Thanks Alan! Also thanks to everyone else who had
> suggestions.
>
> rob.
>
> -----Original Message-----
> From: Alan Brown [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 28, 2001 2:19 PM
> To: Mize, Robert
> Subject: Re: [PHP-WIN] COM objects win2000 PHP4.02
>
> Probably the user account that the web site is running under (looks like
> IIS, so IUSR_<MACHINENAME>) does not have permission to instantaite the word
> component. What are the permissions on the directory containing winword.exe
> and on the exectuable itself? It could be instatitation permsisions (which
> are stored in the registry - see dcomcnfg.exe) or on the exectuable.
>
> Alan.
> ----- Original Message -----
> From: "Mize, Robert" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, August 28, 2001 13:29
> Subject: [PHP-WIN] COM objects win2000 PHP4.02
>
> > I am having issues instantiating word or excel using COM.
> >
> > I get the error:
> > Warning: Unable to obtain IDispatch interface for CLSID
> > {000209FF-0000-0000-C000-000000000046}: Access is denied. in
> > C:\Inetpub\wwwroot\website\excel\word.php on line 3
> > Unable to instanciate Word
> > Line 3 is:
> > $word = new COM("word.application") or die("Unable to instantiate Word");
> >
> > I have changed permissions everywhere I can think of (office executables
> and
> > web dirs), I have added com.allow_dcom = true to php.ini. I'm not sure
> > what else to try.
> >
> > Anyone know what I am doing wrong?
> >
> > Thanks,
> > rob.
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]