Error from PHP with COM: Creating simple Words doc
| From: | Wee Keat [VisualDensity] | Date: | Mon, 02 Jun 2003 10:04:14 +0000 |
| Subject: | Error from PHP with COM: Creating simple Words doc | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-20156@lists.php.net to get a copy of this message | ||
Hi all...
I was trying out PHP and COM on my WinXP machine with IIS 5 and I used the following code, which was
an example from the PHP manual:
/*
######################### the code #####################
*/
<?php
// 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 = 0;
//open an empty document
$word->Documents->Add();
//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("UselessTest.doc");
//closing word
$word->Quit();
//free the object
$word->Release();
$word = null;
?>
/*
######################### end of code #####################
*/
It didn't work at all... so I do not know how else I could experiment. This is the error:
/*
######################### the error #####################
*/
Loaded Word, version 10.0
Warning: Invoke() failed: Exception occurred.
Source: Microsoft Word Description: Could not open macro storage. in
C:\Inetpub\wwwroot\Practice\COM.php on line 18
Warning: Invoke() failed: Exception occurred.
Source: Microsoft Word Description: The requested member of the collection does not exist. in
C:\Inetpub\wwwroot\Practice\COM.php on line 22
/*
######################### end of error #####################
*/
I have tried Googling it... and it seems that someone else have the same problem.... but
unfortunately, there's no answer to those questions asked. Can anyone give me some pointers?
Any help deeply appreciated. Thanks.
Yours,
Wee Keat Chin
------------------------------------------
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the
universe." - Albert Einstein