Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening word docs with php

Status
Not open for further replies.

shnazz

Technical User
Jul 27, 2004
22
US
Hi,

I seem to have trouble trying to get this to work. Here is my code:

<?php
$word = new COM("word.application") or die("Unable to instantiate Word");

echo "Loaded Word, version {$word->Version}\n";
$word->Visible = 1;
$template_file = "C:\Documents and Settings\user\Desktop\test.doc";

$word->Documents->Open($template_file);

$word->Quit();

$word = null;
?>

These are the errors I get:

Warning: main(): Unable to lookup Version: Call was rejected by callee. in C:\Apache\Apache2\htdocs\COMtest.php on line 12
Loaded Word, version
Warning: main(): Unable to lookup Visible: Call was rejected by callee. in C:\Apache\Apache2\htdocs\COMtest.php on line 14
Warning: (null)(): Unable to lookup Documents: Call was rejected by callee. in C:\Apache\Apache2\htdocs\COMtest.php on line 17
Warning: (null)(): Unable to lookup quit: Call was rejected by callee. in C:\Apache\Apache2\htdocs\COMtest.php on line 21

Some background info: I do have office 2000 pro installed on the server. My PHP version is 4.3.7

The php configuration for COM is:
com
Directive Local Value Master Value
com.allow_dcom Off Off
com.autoregister_casesensitive On On
com.autoregister_typelib Off Off
com.autoregister_verbose Off Off
com.typelib_file no value no value

Any help is GREATLY appreciated.

:)
 
If you are running this script via a web server, you are going to have only limited success running Word. This is because Word must interact with the desktop to operate.

You might be able to get something done by givning Apache permission to interact with the desktop. But I strongly recommend against running desktop applications from a web server.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thank you for clearing that up. I temporarily put the file on the server just to play with it and it opens.

Is there any way to display the document in the word web viewer? I am looking at the Word COM and am having difficulty finding a reference to it.

Is there an easier way to view word docs in their original format via a web browser?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top