const // kleine Auswahl verschiedener Formen
msoShapeRectangle = 1;
msoShapeOctagon = 6;
msoShapeOval = 9;
msoShapeHexagon = 10;
msoShapeRegularPentagon = 12;
msoShapeDonut = 18;
msoShapeHeart = 21;
msoShapeSun = 23;
msoShapeDownArrow = 36;
msoShapeExplosion1 = 89;
msoShapeDoubleWave = 104;
var
WordApp, Dokument, Shape: OleVariant;
procedure TForm1.Button3Click(Sender: TObject);
begin
WordApp := CreateOleObject('Word.Application');
try
Dokument := WordApp.Documents.Add;
// Form hinzufügen
Shape := Dokument.Shapes.AddShape(msoShapeDoubleWave, 50, 50, 100, 100);
// Form nach links drehen
Shape.Rotation := -20;
// Farben festlegen
Shape.Fill.ForeColor.RGB := colortoRGB(clFuchsia);
Shape.Fill.BackColor.RGB := colortoRGB(clBlue);
Shape.Line.ForeColor.RGB := colortoRGB(clYellow);
// Muster und Transparenz festlegen
Shape.Fill.Patterned(43);
Shape.Fill.Transparency := 0.7; // 0..1
// Linienbreite
Shape.Line.Visible := True;
Shape.Line.Weight := 2.1;
// Form hinter den Text
Shape.WrapFormat.Type := 3;
Shape.ZOrder(5);
// Schrift festlegen
WordApp.Selection.Font.Name := 'Arial';
WordApp.Selection.Font.Size := 22;
WordApp.Selection.Font.Color := colortoRGB(clBlack);
WordApp.Selection.TypeText('Das ist ein Test');
Dokument.SaveAs('c:\Test.doc');
WordApp.Visible := true;
except
if not VarIsEmpty(WordApp) then WordApp.Quit;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
try
if not VarIsEmpty(WordApp) then WordApp.Quit;
except end;
end;