<?php
set_time_limit(0);
error_reporting(E_ALL);
$empty = new VARIANT();
com_load_typelib('Word.Application');
$word = new COM('word.application') or die('无法加载 Word');
print "加载 Word,版本 {$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 已关闭。\n";
?>
示例文档为…
您好 [YourName 书签],您 [YourAge 书签] 岁了。
并且它将被调用为…
word.php?YourName=Richard%20Quadling&YourAge=35
此致,
Richard。