How to use PHP & Word (Word.Application) - BuiltInDocumentProperties The Learn / Lutorial / Sctipts php programming how to using PHP and Word BuiltInDocumentProperties.
ShotDev Focus:
- PHP & Word BuiltInDocumentProperties.
Example
php_word_builtin.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? $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.ShotDev.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="<?=$DocName?>">Click here</a> to Download. </body> </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_word_builtin.php
Screenshot
2lexicon…
…