unit UMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Word2000, OleServer, StdCtrls, Word97;
type
TForm1 =
class(TForm)
Button1: TButton;
WordApplication1: TWordApplication;
WordDocument1: TWordDocument;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var FileName:OleVariant;
vWhat, vBookmark:OleVariant;
begin
if OpenDialog1.Execute
then
FileName := OpenDialog1.FileName
else
exit;
vWhat:=wdGoToBookmark;
WordApplication1.Connect;
WordApplication1.Documents.OpenOld(FileName, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam);
WordDocument1.ConnectTo(WordApplication1.ActiveDocument);
WordApplication1.Visible := True;
vBookmark:='
Name';
WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
WordApplication1.Selection.TypeText('
Max Mustermann'#13'
Dorfstraße 100');
vBookmark:='
Ort';
WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
WordApplication1.Selection.TypeText('
12345 Sowieso');
vBookmark:='
Schrift';
WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
WordApplication1.Selection.TypeText('
Testausgabe');
vBookmark:='
RechnungText';
WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
WordApplication1.Selection.TypeText('
Posten1'#13'
Posten2'#13'
Posten3');
vBookmark:='
RechnungBetrag';
WordApplication1.Selection.GoTo_(vWhat,emptyParam,emptyParam,vBookmark);
WordApplication1.Selection.TypeText('
1.209,09'#13'
200,32'#13'
22.093.00');
end;
end.