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!
<?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;
?>
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
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.