Title: DOC to PRN
Question: Needing to create a PRN file from a Word Document?
This works with the Word97 components and to make it work with the Word2000 components, some function calls and parameters must be changed.
Answer:
var
DocFile, PrnFile,
Background, Append, Range, OutputFileName,
From, To_, Item, Copies, Pages, PageType,
PrintToFile, Collate, FileName,
ActivePrinterMacGX, ManualDuplexPrint: OleVariant;
begin
DocFile := 'C:\test.doc';
PrnFile := 'c:\test.prn';
WordApplication1.Connect;
Background := True;
Append := EmptyParam;
Range := wdPrintAllDocument;
OutputFileName := PrnFile;
From := '';
To_ := '';
Item := wdPrintDocumentContent;
Copies := 1;
Pages := '1';
PageType := wdPrintAllPages;
PrintToFile := True;
Collate := EmptyParam;
FileName := DocFile;
ActivePrinterMacGX := EmptyParam;
ManualDuplexPrint := EmptyParam;
WordApplication1.Visible := False;
WordApplication1.Documents.Open(DocFile,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam);
WordDocument1.ConnectTo(WordApplication1.ActiveDocument);
WordDocument1.PrintOut(Background,
Append,
Range,
OutputFileName,
From,
To_,
Item,
Copies,
Pages,
PageType,
PrintToFile,
Collate,
FileName,
ActivePrinterMacGX);
WordApplication1.Disconnect;
WordApplication1.Quit;
end;