How to use PHP & Word (Word.Application) - Open Document (Documents.Open)
How to use PHP & Word (Word.Application) - Open Document (Documents.Open) The Learn / Lutorial / Sctipts php programming how to using PHP open word document and write text into same document.
ShotDev Focus:
- PHP & Open word document and write text into same document.
- PHP & Open word document and write text into same document.
Example
php_open_word.php
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- <?
- $wdAlignParagraphCenter = "1";
- $Wrd = new COM("Word.Application");
- $DocName = "MyDoc/MyWord.doc";
- //$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
- $Wrd->Application->Visible = False;
- $WrdDoc = $Wrd->Documents->Open(realpath("shotdev.dot"));
- $MyRange1 = $WrdDoc->Range();
- $MyRange1->ParagraphFormat->Alignment = $wdAlignParagraphCenter;
- $MyRange1->Font->Name = "Verdana";
- $MyRange1->Font->Size = "30";
- $MyRange1->Font->Bold = True;
- $MyRange1->InsertBefore(chr(13).chr(13)."www.ShotDev.Com".chr(13)."Version 2010".chr(13));
- $MyRange1 = $WrdDoc->Paragraphs->Add->Range;
- $MyRange1->InlineShapes->AddPicture(realpath("logo.gif"));
- $MyRange1 = $WrdDoc->Paragraphs->Add->Range;
- $MyRange1->ParagraphFormat->Alignment = $wdAlignParagraphCenter;
- $MyRange1->Font->Name = "Verdana";
- $MyRange1->Font->Size = "13";
- $MyRange1->Font->Bold = True;
- $MyRange1->InsertBefore(chr(13).chr(13).chr(13).chr(13)."All Rights Reserved.");
- //$WrdDoc->SaveAs($strPath."/".$DocName);
- $WrdDoc->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/
Screenshot
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment