word: php + com trouble

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
quarry_06
Forum Newbie
Posts: 2
Joined: Wed Feb 16, 2005 6:37 am

word: php + com trouble

Post by quarry_06 »

Hi
I have following code:

Code: Select all

com_load_typelib('Word.Application');

error_reporting(E_ALL);

$empty = new VARIANT();
$Word = new COM('word.application') or die('Unable to load Word');

$Word->Documents->Open("C:\\zert.doc");
$Word->Selection->GoTo(wdGoToBookmark,$empty,$empty,'CertNumber');
//crucial line
$Word->Selection->TypeText("some text");
$Word->Documentsї1]->SaveAs("C:\\some_file.doc");
When I comment line with GoTo, the script executes fine, but when I uncomment it, the script doesn't work.
and I the heck don't know why. I am loading the constant wdGoToBookmark with the function com_load_typelib('Word.Application');, so this should work.

I don't get an error, but simply the script never stops and I get an error that apache2.exe has crashed.

do I have to install anything to use these com functions?
or why does it not work

any help very appreciated!!!

quarry
Post Reply