I am having trouble finding anyone who knows much about COM. Anyhow, I am def a nub and created a function to clean this up a bit.
Now the browser is just taking forever to process the request, actually, just stuck in process mode and wont complete the process.
Here is the new code:
<?php
function Bookmark($form, $bookmark)
{
$objBookmark = $word->ActiveDocument->Bookmarks($bookmark);
$range = $objBookmark->Range;
$range->Text = $form;
}
$input = "C:/server/test.doc";
$name = $_POST['name'];
$agencyname = $_POST['agencyname'];
$street = $_POST['street'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$email = $_POST['email'];
$bookmarkname = 'text67';
$bookmarkagency = 'text45';
$bookmarkstreet = 'text46';
$bookmarkcity = 'Text53';
$bookmarkstate = 'Text47';
$bookmarkzip = 'Text48';
$bookmarkphone = 'Text49';
$bookmarkfax = 'Text50';
$bookmarkemail = 'Text51';
$word = @new COM("word.application") or die("Unable to instantiate Word");
$word->Visible = 1;
$word->Documents->Open($input);
Bookmark($name, $bookmarkname);
Bookmark($agencyname, $bookmarkagency);
Bookmark($street, $bookmarkstreet);
Bookmark($city, $bookmarkcity);
Bookmark($state, $bookmarkstate);
Bookmark($zip, $bookmarkzip);
Bookmark($phone, $bookmarkphone);
Bookmark($fax, $bookmarkfax);
Bookmark($email, $bookmarkemail);
print "Thank you for submitting your license agreement.";
// Save the document.
$new_file = "C:/server/$agencyname.doc";
$word->Documents[1]->SaveAs($new_file);
// closing word
$word->Quit();
$word = null;
?>
Please please please someone leave some feedback on this... my brain hurts.