PHP / COM

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
HoolyDooly
Forum Newbie
Posts: 1
Joined: Wed May 15, 2002 8:32 am

PHP / COM

Post by HoolyDooly »

Hi everyone, the purpose of my php script is to write some words in a word document and then save & print it.

// starting word
$word = new COM("word.application") or die("Unable to instanciate Word");

$word->Visible = 1;

$word->Documents->Add();


$word->Selection->TypeText("Test1");

$word->Selection->TypeParagraph();

$word->Selection->TypeParagraph();

$word->Selection->TypeText("Test2");

$word->Selection->TypeParagraph();

$word->Selection->TypeParagraph();

$word->Selection->TypeText("Test3");

$word->PrintOut();

$word->Documents[1]->SaveAs("c:\\PHP Word Output.doc");

//closing word
$word->Quit();

//free the object from the memory
$word->Release();
$word = null;

Everything is working fine except the $word->PrintOut() function which delivers the following error message:

Warning: Invoke() failed: Exception occured. Source: Microsoft Word Description: Printing is not possible; no printer is installed.

The PHP Server got 3 Printers in its Windows Printer Folder (connected via LAN) so there are printers installed.

Anyone got a clue ?
Power
Forum Newbie
Posts: 2
Joined: Fri May 17, 2002 6:15 am
Location: Hong Kong

About Word printing (COM)

Post by Power »

I tried your code in my Win98, Office 97, Apache, PHP4 environment, it seems OK to me. It will ask me to answer yes or no to quit the Word or not as it will cancel the printing. If I answer "No", it will print out. If "Yes", it will not print. Both cases will have an error message "Warning: Unable to lookup release: Call was rejected by callee. in c:\program files\Apache Group\Apache\htdocs/wordprint.php on line 32" showing in my browser. I tested it on both of my Win98 Apache server and a Windows client's browser to call your php file. Both's results are the same.
And do you know how can we use php to call a Word or Excel program to open a file in a client instead of open in the server? Or it is not possible?[/quote]
Post Reply