Saving to MS Word Format

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
curious
Forum Newbie
Posts: 1
Joined: Tue Mar 30, 2004 3:41 am

Saving to MS Word Format

Post by curious »

Hello Guys,

I am working on an applications that needs certain data fetched from database and saved as an MS Word document. Can someone please give me directions on how to save as MS Word or RTF format ?

Thanks,
Curious
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

For starters you need to be on a windows server becuase you need to use the COM functions/

Here is how you wold write a word document

Code: Select all

<?
$word=new COM("word.application") or die("Cannot start MS Word"); 
print "Loaded word version ($word->Version)\n"; 
$word->visible = 1 ; 
$word->Documents->Add(); 
$word->Selection->Typetext("This is a test");
$word->Documents[1]->SaveAs("E:\\test_doc.doc",8);
$word->Quit();
$word->Release();
$word = null;
?>
Mark
Post Reply