Bonjour,
Je souhaite éditer un document word automatiquement.
Cela marche très bien, mais après modification, j'obtient un nouveau document Word 'document1'.
J'aimerais sauver automatiquement ce document en lui attribuant un nom.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
procedure TForm1.Button11Click(Sender: TObject);
var
  Fword,FDocument,FFindObject:OleVariant;
  Filename:String;
 
begin
   Filename := 'C:\temp\A_Editer.doc';
   Fword := CreateOleObject('Word.Application');
   FDocument := Fword.Documents.Add(Filename);
   FFindObject := FDocument.ActiveWindow.Selection.Find;
   Fword.visible := true;
   FFindObject.ClearFormatting;
   FFindObject.Replacement.ClearFormatting;
   FFindObject.Text := 'xxx2'; //balise qui sera remplacée par le texte du 'test.rtf'
   FFindObject.Forward := True;
   FFindObject.Replacement.Text := '';
   FFindObject.Wrap := 1;
   FFindObject.MatchCase := False;
   FFindObject.MatchWholeWord := False;
   FFindObject.MatchWildcards := False;
   FFindObject.MatchSoundsLike := False;
   FFindObject.MatchAllWordForms := False;
 
   if FFindObject.Execute() then Fword.selection.InsertFile('C:\temp\test.rtf');
   end;
Merci pour votre aide
PhilLu