COM class (PHP+Word)

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
hulio
Forum Newbie
Posts: 1
Joined: Thu Mar 04, 2004 9:04 am

COM class (PHP+Word)

Post by hulio »

I use Apache 2.0 and PHP 4.3. on Windows2000.

I want to use Word with PHP and I wrote an example from php.net Manual:

Code: Select all

<?php 
// starting word 
$word = new COM("word.application") or die("Unable to instanciate 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->Release(); 
$word = null; 
?>

and when I start this code I get two warnings:

Loaded Word, version 8.0
Warning: (null)(): Invoke() failed: Type mismatch. Argument: 2 in D:\Program Files\Apache Group\Apache2\htdocs\word.php on line 13

Warning: (null)(): Invoke() failed: Type mismatch. Argument: 2 in D:\Program Files\Apache Group\Apache2\htdocs\word.php on line 14


I set up com.allow_dcom=true in php.ini.

Could anyone tell me what the problem is ?
Post Reply