Page 1 of 1

Saving to MS Word Format

Posted: Tue Mar 30, 2004 3:41 am
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

Posted: Tue Mar 30, 2004 3:48 am
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