Piloter Word par OLE

uses comobj;

procedure TForm1.Button1Click(Sender: TObject);
var
word : var iant;

begin
try
word := CreateOleObject('Word.Application');
except
ShowMessage('Word n'a pas pu ętre lancé!');
Exit;
end;
word.Visible := True;
word.Documents.Add;
If word.ActiveWindow.View.SplitSpecial <> 0 Then
word.ActiveWindow.Panes[2].Close;
If (word.ActiveWindow.ActivePane.View.Type = 1) Or
(word.ActiveWindow.ActivePane.View.Type = 2) Or
(word.ActiveWindow.ActivePane.View.Type = 5) Then
word.ActiveWindow.ActivePane.View.Type := 3;
word.ActiveWindow.ActivePane.View.SeekView := 9;
word.Selection.Font.Name := 'Times New Roman';
word.Selection.Font.Size := 12;
word.Selection.Font.Bold := True;
word.Selection.ParagraphFormat.Alignment := 1;
word.Selection.TypeText(Text:='Kohlenhandel Brikett-GmbH & Co.-KG. - Holzweg 16 -
54633 Steinhausen');
If word.Selection.HeaderFooter.IsHeader = True Then
word.ActiveWindow.ActivePane.View.SeekView := 10
Else
word.ActiveWindow.ActivePane.View.SeekView := 9;
word.Selection.TypeText(Text:= 'Bankverbindung: Stadtsparkasse Steinhausen BLZ
123456789 KtoNr. 782972393243');
word.ActiveWindow.ActivePane.View.SeekView := 0;
word.Selection.TypeText(Text:=Edit2.Text + ' ' + edit1.Text);
word.Selection.TypeParagraph;
word.Selection.TypeText(Text:=edit3.Text);
word.Selection.TypeParagraph;
word.Selection.TypeParagraph;
word.Selection.Font.Name := 'Times New Roman';
word.Selection.font.Size := 12;
word.Selection.font.Bold := True;
word.Selection.TypeText(Text:=edit4.Text + ' ' + edit5.Text);
word.Selection.TypeParagraph;
word.Selection.TypeParagraph;
word.Selection.TypeParagraph;
word.Selection.TypeParagraph;
word.Selection.Font.Name := 'Arial';
word.Selection.Font.Size := 14;
word.Selection.Font.Bold := True;
word.Selection.TypeText(Text:=Combobox1.Text);
word.Selection.TypeParagraph;
word.Selection.TypeParagraph;
word.Selection.TypeParagraph;
word.Selection.Font.Name := 'Times New Roman';
word.Selection.Font.Size := 12;
word.Selection.Font.Bold := True;
If radiogroup1.itemindex= 0 Then
word.Selection.TypeText(Text:='Sehr geehrter Herr ' + edit1.Text)
Else
word.Selection.TypeText(Text:='Sehr geehrte Frau ' + edit1.Text);
end;
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour26/02/2004
VisualisationVu 3113 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Objet
Auteur de l'article
Communauté Delphi Communauté Delphi
connecté le 02/11/2011
0 articles dans la section
Contacter l'auteur