Problem to open wordpad

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
mubeena
Forum Newbie
Posts: 17
Joined: Fri Jan 30, 2009 4:26 am

Problem to open wordpad

Post 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
Last edited by Benjamin on Sat Jun 06, 2009 1:28 pm, edited 1 time in total.
Reason: Added [code=php] and [quote] tags.
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: Problem to open wordpad

Post by akuji36 »

when working with php I like

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


http://www.blumentals.net/rapidphp/
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: Problem to open wordpad

Post 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\...
Post Reply