The following code apparently should open a word document from the browser bring it to the front, change it and then save as a new file. But nothing happens the browser turns blank upon the call and then just loads constantly till it times out!! Any help would be greatly appreciated!
(i have double checke the template is correct and holds relevant bookmark, and the file root is also correct)
<?php
//1. Instanciate Word
$word = new COM("word.application") or die("Unable to instantiate Word");
//2. specify the MS Word template document (with Bookmark TODAYDATE inside)
//bring word to the front
$word->visible = 1;
$template_file = "C:/web/sundance/Delivery Notes/Delivery_Templates.doc";
//3. open the template document
$word->Documents->Open($template_file);
//4. get the current date MM/DD/YYYY
$current_date = date("m/d/Y");
//5. get the bookmark and create a new MS Word Range (to enable text substitution)
$bookmarkname = "DATE";
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
//6. now substitute the bookmark with actual value
$range->Text = $current_date;
//7. save the template as a new document (c:/reminder_new.doc)
$new_file = "C:/web/sundance/Delivery Notes/Delivery_Templates_NEW.doc";
$word->Documents[1]->SaveAs($new_file);
//8. free the object
$word->Quit();
$word->Release();
$word = null;
?>