PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old January 20th, 2004, 05:00 PM
cbutler cbutler is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Brisbane Australia
Posts: 1 cbutler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP COM to work with Word documents

Hi I am fairly new to PHP and wanting to use fields from my MySQL database to populate a letter created in Ms Word using bookmarks

I am using the following line of code

<?

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

?>

But I get the error message "Unable to instantiate Word "

Could anyone help me please

Thanx in advance
cbutler

Reply With Quote
  #2  
Old January 20th, 2004, 06:30 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Here's some example code to write to word documents:
PHP Code:
<?php 
$word
=new COM("Word.Application") or die("Cannot start word for you"); 
print 
"Loaded word version ($word->Version)\n"

$word->visible =
$word->Documents->Add(); 
$word->Selection->Typetext("Writing This Message ...."); 
$word->Documents[1]->SaveAs("c:\just_a_test2.doc"); 
$word->Quit(); 
print 
"Done ...........\n"
?>


But I assume you have that...

Personally I just tried the code...
After waiting a while, I received an error from Office pop up (in my windows session, not on my php page)... after installing the proper CAB file from my Office CD, and refreshing the page, it worked.

Some possible issues you may be encountering... The COM class only works in Windows... perhaps "Word.Application" is case sensitive...

Reply With Quote
  #3  
Old January 20th, 2004, 08:52 PM
aboyousif aboyousif is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Tanta, Egypt
Posts: 21 aboyousif User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 23 sec
Reputation Power: 0
Send a message via AIM to aboyousif Send a message via MSN to aboyousif Send a message via Yahoo to aboyousif
MadCowDzz ..
Do you Know a good book about php that talk about advanced php and COM ???

please recommend one or two .. and i hope that it has an arabic translated copy ..

Reply With Quote
  #4  
Old January 20th, 2004, 09:29 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
PHP's documentation of the COM class is excellent... its definately helped me out in the past...
http://www.php.net/manual/en/ref.com.php

not too sure about arabic translations... =)

I haven't heard of any specific books about PHP/COM specifically, but I'm sure any good Advaced PHP book would help you out...

I've read Web Application Development with PHP 4.0 (Amazon link)

It does have a small section specifically referring to COM

Reply With Quote
  #5  
Old January 20th, 2004, 09:34 PM
aboyousif aboyousif is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Tanta, Egypt
Posts: 21 aboyousif User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 23 sec
Reputation Power: 0
Send a message via AIM to aboyousif Send a message via MSN to aboyousif Send a message via Yahoo to aboyousif
Thanks Alot My Friend ..

I will try to get this book ..

Reply With Quote
  #6  
Old January 21st, 2004, 05:53 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
You are trying to learn a specific feature of PHP, so it is recommended to get in touch with tutorials instead of a book for now.

If tutorials doesn't helps, then only you should go for a book.
__________________
ExoHelpDesk
ExoCrew Free Services

Reply With Quote
  #7  
Old January 21st, 2004, 06:14 PM
aboyousif aboyousif is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Tanta, Egypt
Posts: 21 aboyousif User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 23 sec
Reputation Power: 0
Send a message via AIM to aboyousif Send a message via MSN to aboyousif Send a message via Yahoo to aboyousif
dear mike ..

i think book will be much useful than tutorials ..
the tutorials just tells you the method to do that ... but the good book tells you the method and the ideology of it .. it will be greater to know this .. i like books if the feature not common or hard to understand .. may be i wrong .. but i see i learn more from books ..

finally thanks for your advice ... it is really appreciated ...

Reply With Quote
  #8  
Old January 21st, 2004, 10:14 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
I agree with mike...

If you're looking into advanced topics in general, then i recommend the book...
but if you specifically want to know the COM class, I'd recommend the PHP manual...
most books wouldn't cover the class as extensively and thoroughly as you may hope for

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP COM to work with Word documents


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway