Improving the code
the document. To check whether the bookmark exists in the template document,
use this:
<?php
if($word->ActiveDocument->Bookmarks->Exists($bookmarkname))
{
//then create a Range and perform the substitution<br>
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
//now substitute the bookmark with actual value
$range->Text = $current_date;
}
?>
highlighted and defined as the bookmark will be deleted. If you want to insert
text before the bookmark, use the following:
<?php
$range->InsertBefore("Today's date is: ");
?>
<?php
$range->InsertAfter("Have a nice day!");
?>
<?php
$pagecontent = $word->ActiveDocument->Content->Text;
?>
the PHP file):
<?php
header('Content-Type: application/msword');
header("Content-Disposition: attachment; filename="Reminder New.doc"");
readfile($new_file);
?>
<?php
header('Content-Type: application/msword');
header("Content-Disposition: attachment; filename="Reminder New.doc"");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
readfile($new_file);
?>
error or terminates unexpectedly. Run Windows Task Manager and end WINWORD.EXE
instance.
code.
Kometsoft (M) Sdn. Bhd.