<html> <head> <title>ThaiCreate.Com PHP Word.Application Tutorial</title> </head> <body> <?php $Wrd = new COM("Word.Application"); $Wrd->Application->Visible = False; $Wrd->Documents->Add(); $DocName = "MyDoc/MyWord.doc"; //$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp $Wrd->Selection->Font->Name = "Verdana"; $Wrd->Selection->Font->Size = "25"; $Wrd->Selection->Font->Bold = True; $Wrd->Selection->Font->Italic = True; $Wrd->Selection->TypeText("Welcome To www.ThaiCreate.Com"); $Wrd->ActiveDocument->BuiltInDocumentProperties("Title")->Value = "Doc Title"; $Wrd->ActiveDocument->BuiltInDocumentProperties("Subject")->Value = "Doc Subject"; $Wrd->ActiveDocument->BuiltInDocumentProperties("Author")->Value = "Doc Author"; $Wrd->ActiveDocument->BuiltInDocumentProperties("Manager")->Value = "Doc Manager"; $Wrd->ActiveDocument->BuiltInDocumentProperties("Company")->Value = "Doc Company"; $Wrd->ActiveDocument->BuiltInDocumentProperties("Category")->Value = "Doc Category"; $Wrd->ActiveDocument->BuiltInDocumentProperties("Application Name")->Value = "Doc Application Name"; $Wrd->ActiveDocument->BuiltInDocumentProperties("Keywords")->Value = "Doc Keywords"; $Wrd->ActiveDocument->BuiltInDocumentProperties("Comments")->Value = "Doc Comments"; //$Wrd->ActiveDocument->SaveAs($strPath."/".$DocName); $Wrd->ActiveDocument->SaveAs(realpath($DocName)); $Wrd->Application->Quit; $Wrd = null; ?> Word Created <a href="<?php echo $DocName?>">Click here</a> to Download. </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท