I have the following script to generate a Microsoft Word file (actually it just fills in the bookmarks in template.doc):
However, it produces the following error message:PHP Code:<?
//1. Instanciate Word
$word = new COM("word.application") or die("Unable to instantiate Word");
//2. specify the MS Word template document
$template_file = "c:/avishai/php/manager/invoice/template.doc";
//3. open the template document
$word->Documents->Open($template_file);
//4. put '734' in the 'id' bookmark
$id = 734;
//5. get the bookmark and create a new MS Word Range (to enable text substitution)
$bookmarkname = "id";
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
//6. now substitute the bookmark with actual value
$range->Text = $id;
//7. save the template as a new document (c:/reminder_new.doc)
$new_file = "c:/avishai/php/manager/invoice/test.doc";
$word->Documents[1]->SaveAs($new_file);
//8. free the object
$word->Quit();
$word->Release();
$word = null;
?>
Warning: (null)(): Invoke() failed: Type mismatch. Argument: 2 in c:\avishai\php\manager\invoice\process.invoice.php on line 19
And the file does not get produced.
Any ideas???? Thanks in advance,
Shai






Bookmarks