1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| <?php
$file = "eco-rev.doc";
$out = "out.doc";
$date = date(D-M-Y);
$MRMME = "M";
$NOM = "Dupond";
set_time_limit(0);
// Pour les fonctions où certains param doivent être vides.
$empty = new VARIANT();
// Chargement de la biblio.
com_load_typelib('Word.Application');
$word = new COM('word.application') or die('Unable to load Word');
print "$word->Version}\n";
// On ouvre le doc
$word->Documents->Open($file);
// On remplace le texte aux signets
$word->Selection->GoTo(wdGoToBookmark,$empty,$empty,'DATE'); // Note use of wdGoToBookmark, from the typelibrary and the use of $empty.
$word->Selection->TypeText($date);
$word->Selection->GoTo(wdGoToBookmark,$empty,$empty,'MRMME');
$word->Selection->TypeText($MRMME);
$word->Selection->GoTo(wdGOTOBookmark,$empty,$empty,'NOM');
$word->Selection->TypeText($NOM);
// On sauve et on ferme
$word->Documents[1]->SaveAs($out);
$word->Quit();
$word->Release();
$word = null;
print "Word closed.\n";
?> |
Partager