Link to home
Start Free TrialLog in
Avatar of wimmeyvaert
wimmeyvaert

asked on

Printing amount of copies of Word Document from Delphi-app ...

Hi experts,

I want to print a word-document from my delphi-application (preferable is that Word itself won't open).
I want to be able to dynamically determine the documentname and number of copies to print.
Please feed me with some code if possible.
Thanks in advance,

The Mayor.
Avatar of shaneholmes
shaneholmes

Take a look at the TWordApplication component on the servers tab of the component palette

  WordApplication1.Connect;
  WordDocument1.PrintOut();  //here is where you decribe all your parameters example: copies
  WordApplication1.Disconnect;
  WordApplication1.Quit;

Shane
ASKER CERTIFIED SOLUTION
Avatar of shaneholmes
shaneholmes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wimmeyvaert

ASKER

Hi shaneholmes,

I will take a closer look at the example.
I'll be back ...

Best regards,

The Mayor.
Hi shaneholmes,

It works !!!!
I looked at the URL you gave in your second comment. Ther I found the complete anwser to my question.

This is the solution I used :

var
 DocFile, PrnFile,
 Background, Append, Range, OutputFileName,
 From, To_, Item, Copies, Pages, PageType,
 PrintToFile, Collate, FileName,
 ActivePrinterMacGX, ManualDuplexPrint: OleVariant;
 Doc, Word : OleVariant;
begin
 DocFile := 'C:\test.doc';
 PrnFile := 'c:\test.prn';
 Word := CreateOleObject('Word.Document.6');
 Background := False;
 Append := EmptyParam;
 Range := 0;
 OutputFileName := PrnFile;
 From := '';
 To_ := '';
 Item := 0;
 Copies := 1;
 Pages := '1';
 PageType := 0;
 PrintToFile := True;
 FileName := DocFile;
 Collate := EmptyParam;
 ActivePrinterMacGX := EmptyParam;
 ManualDuplexPrint := EmptyParam;
 word.Application.Visible := false;

 Word.Application.PrintOut(Background,
                        Append,
                        Range,
                        OutputFileName,
                        From,
                        To_,
                        Item,
                        Copies,
                        Pages,
                        PageType,
                        PrintToFile,
                        Collate,
                        FileName,
                        ActivePrinterMacGX);


Thanks a lot for the fast response !

Best regards,

The Mayor.