With thanks to Harald Radi and Wez Furlong.
Some VBA functions have optional parameters. Sometimes the parameters you want to pass are not consecutive.
e.g.
GoTo What:=wdGoToBookmark, Name="BookMarkName"
GoTo(wdGoToBookmark,,,"BookMarkName)
In PHP, the "blank" parameters need to be empty.
Which is ...
<?php
set_time_limit(0);
error_reporting(E_ALL);
$empty = new VARIANT();
com_load_typelib('Word.Application');
$word = new COM('word.application') or die('Unable to load Word');
print "Loaded Word, version {$word->Version}\n";
$word->Documents->Open('C:/Unfilled.DOC');
$word->Selection->GoTo(wdGoToBookmark,$empty,$empty,'YourName'); $word->Selection->TypeText($_GET['YourName']);
$word->Selection->GoTo(wdGoToBookmark,$empty,$empty,'YourAge');
$word->Selection->TypeText($_GET['YourAge']);
$word->Documents[1]->SaveAs("C:/{$_GET['YourName']}.doc");
$word->Quit();
$word->Release();
$word = null;
print "Word closed.\n";
?>
The example document is ...
Hello [Bookmark of YourName], you are [Bookmark of YourAge] years old.
and it would be called ...
word.php?YourName=Richard%20Quadling&YourAge=35
Regards,
Richard.