Page 1 of 1

Problem to open wordpad

Posted: Fri Jan 30, 2009 4:42 am
by mubeena
hai,
i want to open a wordpad, using the PHP.
If i tried this code,

Code: Select all

<?php
 
// Some servers may have an auto timeout, so take as long as you want.
set_time_limit(0);
 
// Show all errors, warnings and notices whilst developing.
error_reporting(E_ALL);
 
// Used as a placeholder in certain COM functions where no parameter is required.
$empty = new VARIANT();
 
// Load the appropriate type library.
com_load_typelib('Word.Application');
 
// Create an object to use.
$word = new COM('word.application') or die('Unable to load Word');
 
print "Loaded Word, version {$word->Version}\n";
 
// Open a new document with bookmarks of YourName and YourAge.
$word->Documents->Open('C:/web/Sundance/Delivery Notes/Delivery_Template.doc');
 
?>
I am getting the error message,
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': Access is denied. ' in D:\DocStation\testing_MIME\11.php:79 Stack trace: #0 D:\DocStation\testing_MIME\11.php(79): com->com('word.applicatio...') #1 {main} thrown in D:\DocStation\testing_MIME\11.php on line 79
Can anyone give me as suggesstion to solve this issue?

Regards,
Jasmine

Re: Problem to open wordpad

Posted: Sat Jun 06, 2009 11:28 am
by akuji36
when working with php I like

blumenthals rapid php editor: it can offer error highlighting and more


http://www.blumentals.net/rapidphp/

Re: Problem to open wordpad

Posted: Sat Jun 06, 2009 12:16 pm
by mikemike
At first glance I have a few suggestions. There are only suggestions as I've never used the COM lib before:

Code: Select all

$word = new COM('word.application') or die('Unable to load Word');
Case sensitive? Perhaps Word.Application like you sued above?

Code: Select all

$word->Documents->Open('C:/web/Sundance/Delivery Notes/Delivery_Template.doc');
Windows uses backward slashes... C:\web\Sundance\...