Hum,,, how does com with php work....

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
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Hum,,, how does com with php work....

Post by PHP_ColdFusion »

i am trying to open an instance of notepad through php.

below is the code.

Code: Select all

<?php

// starting word
$word = new COM("word.application");
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;

?>
but when i run that php file i get this

Code: Select all

Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': Invalid syntax ' in F:\Database Program\WEBPROGRAM\com.php:4 Stack trace: #0 F:\Database Program\WEBPROGRAM\com.php(4): com->com('word.applicatio...') #1 {main} thrown in F:\Database Program\WEBPROGRAM\com.php on line 4
what am i doing wrong
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

heh, ok all references to word.application are acctually notepad.application in the script

i didn't notice i did that

but i still get the error.
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

is Notepad installed on your server? Because if you are trying to open this on the client it will not work. PHP is a server side language. You would need to use javascript or something to open it on the client.
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

i know php is server side but i'm not sure if notepad is installed should be tho its pretty basic windows component lol
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

notepad is installed
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

So are you trying to open up notepad, on the server, or the client's browser?
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

on the server
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

hmmm I have done similar type things using com.... let me find one of my old scripts. I didn't use notepad but may be able to help.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

PHP_ColdFusion wrote:heh, ok all references to word.application are acctually notepad.application in the script
But there is no application id notepad.application. Notepad simply doesn't offer such an interface.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Do you mean wordpad? notepad doesn't open or save .doc files
User avatar
PHP_ColdFusion
Forum Newbie
Posts: 21
Joined: Thu Jan 04, 2007 2:16 pm
Location: Leesville, Louisiana, USA

Post by PHP_ColdFusion »

HUM....well i guess i could use wordpad for it
let me try
Post Reply