procedure Delay(msecs:integer);
var
FirstTickCount:longint;
begin
FirstTickCount:=GetTickCount;
repeat
Application.ProcessMessages;
{allowing access to other controls, etc.}
until ((GetTickCount-FirstTickCount) >= Longint(msecs));
end;
{****************************************************}
procedure TForm1.Button1Click(Sender: TObject);
var
ndx : Integer;
FileName: OleVariant;
i, j: Integer;
s:
string;
begin
Button1.Enabled := False;
ndx := 1;
abbruch := false;
while (ndx < StringGrid1.RowCount - 1)
and (
not abbruch)
do
begin
s := StringGrid1.Cells[8, i];
with TRegistry.Create
do
try
RootKey := HKEY_CURRENT_USER;
if OpenKey('
\Software\VB and VBA Program Settings\FRITZ!fax\Print', True)
then
begin
WriteString('
Microsoft Word - test.doc', s);
end;
finally
CloseKey;
Free;
WordApplication1.Connect;
Application.ProcessMessages;
FileName := '
C:\test.doc';
WordApplication1.Documents.Open(FileName, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam);
WordDocument1.Close;
WordApplication1.PrintOut;
Delay (3000);
WordDocument1.Disconnect;
inc(ndx);
Application.ProcessMessages;
end;
end;
end;
{****************************************************}
procedure TForm1.Button2Click(Sender: TObject);
begin
abbruch := True;
Button1.Enabled := True;
end;