Professional Documents
Culture Documents
Ricks Rants
end;
WordRange := WordApp.ActiveDocument.Content;
WordRange.Find.Execute(SearchString,
EmptyParam, // match case
EmptyParam, // match whole word
EmptyParam, // match wildcards
EmptyParam, // match sounds like
EmptyParam, // match all word forms
EmptyParam, // forward
EmptyParam, // wrap
EmptyParam, // format
ReplaceString, // replace with
2); // replace all
end;
// Set printer
WordAPP.Application.WordBasic.FilePrintSetup (Printer:=PrinterName, DoNotSetAsSysDefault:=1);
// Print
WordApp.ActiveDocument.PrintOut;
// Close the document, do not save original
WordApp.ActiveDocument.Close(0);
// Check that the print has finished before exiting the procedure
while WordApp.BackgroundPrintingStatus>0 do
begin
Sleep(100);
Application.ProcessMessages;
end;
except
on E : Exception do begin
ShowMessage(E.ClassName+ error raised, with message : +E.Message);
WordApp.Quit;
WordApp := Unassigned;
Exit;
end;
end;
// Quit Word
WordApp.Quit;
WordApp := Unassigned;
end;
[/delphi]