Printing Delphi

Title: Ms-Word BackGroundPrintingStatus
Question: This article shows how to wait on a printjob in MS-Word?
Answer:
Uses comobj;
procedure TForm1.Button1Click(Sender: TObject);
var
code : string;
MSWord : olevariant;
begin
if OpenDialog1.execute then
begin
MSWord := CreateOLEObject('Word.Application');
MSWord.Documents.Open (FileName := OpenDialog1.FileName, ReadOnly:=false);
MSWord.Visible := 0;
MSWord.Application.PrintOut(FileName:='', Range:=0, Item:= 0, Copies:=1, Pages:='', PageType:= 0, Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0);
while MSWord.application.backgroundprintingstatus 0 do
begin
MSWord.ActiveDocument.ActiveWindow.Activate;
sleep(1000);
end;
MSWord.quit;
end;
end;