note 88943 deleted from class.com by cmb
| From: | cmb@php.net | Date: | Tue, 05 Nov 2019 09:38:14 +0000 |
| Subject: | note 88943 deleted from class.com by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212900@lists.php.net to get a copy of this message | ||
Note Submitter: pavanphp at sparsh dot net
----
This is the code for entering Values in MS word through Php Program.
First : You need to make word file with including Boolmark
(Ms word 2003 , Insert -> Bookmark ->Bookmark Name -> add).
Example
Name : add here bookmark
This is something like input as a text box. Here I given 5 fields.
Name , TODAYDATE , Company ,project , Features
Here I opened a word file, and put data into Bookmark fields using PHP.
Just note : it works in c:/ only. (not sure why), C:/program files may take longer time. (waiting
for ...)
<?php
com_load_typelib('Word.Application');
$word = new COM("word.application") or die("Unable to instantiate Word");
// use like this. Place your's word file in C drive
$word->Documents->Open('C:/reminder_new.doc');
echo $current_date = date("m/d/Y");
$tim= date("Y-m-d");
$info_array=array( "Name" => "pavan",
"TODAYDATE" => "$tim" ,
"Company" => "sparsh" ,
"project" => "Myrepc",
"Features" => "Auto fill form editor") ;
foreach($info_array as $bookmarkname => $re)
{
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
echo $range->Text = $re ;
}
$new_file = "c:/reminder_filled.doc";
$word->Documents[1]->SaveAs($new_file);
$word->ActiveDocument->Close(false);
$word->Quit();
$word = null;
?>