Hello, this is my first post here... and I'm stuck on COM objects.
I'm trying to open Word via PHP using code taken directly from php.net:
<?php
// starting word
$word = new COM("word.application") or die("Unable to instantiate Word");
echo "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 = null;
?>
(from: http://us3.php.net/manual/en/class.com.php)
I've also gone through this tutorial:
http://www.phpbuilder.com/columns/venkatesan20030501.php3
But I'm still stuck
When I run the above code, "Loaded Word, version 11.0" is outputted, and the task manager shows WINWORD.EXE running under the IUSER_mymachinename" account...
But Word is never made visible, no document is created or saved, and word does not quit (I have to end it in the task manager)
This seems to indicate that Word is in a sort of "read only" state... I can ask it what version it is, but I cannot tell it to do anything
The following also reports back "0" (another "read only" type of item)
echo '<br />'. $word->Documents->Count;
This is my first foray into COM objects, so I don't have any prior experience to draw upon... I'm hoping someone here can shed some light on this
Here's some additional info that might help:
PHP VERSION: 5.2.1
OS: WindowsXP pro
SERVER: IIS5 ("scripts and executables" is turned on)
COM php.ini settings:
[COM]
; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
com.typelib_file = "C:\WINDOWS\system32\activeds.tlb"
; allow Distributed-COM calls
com.allow_dcom = true
; autoregister constants of a components typlib on com_load()
com.autoregister_typelib = true
; register constants casesensitive
;com.autoregister_casesensitive = false
; show warnings on duplicate constant registrations
com.autoregister_verbose = true
I can't help but think I'm missing some configuration setting
Thanks in advance for any pointers