PhilLu
Messages postés251Date d'inscriptionlundi 9 novembre 2009StatutMembreDernière intervention11 mai 2021
-
10 nov. 2015 à 09:31
NABIL74 -
11 nov. 2015 à 20:35
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.
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;