user3271392
user3271392

Reputation: 147

Print a document in MS Word on both sides of paper using delphi xe3

How can i print a Word document on both sides using code in Delphi xe 3?

Below is how the word document is created:

  try
  { Open the document}
   WrdApp := CreateOLEObject('Word.Application');
   wrdDoc := WrdApp.Documents.Open(document);
  // Wrddoc.SaveAs(SaveToFile);
  except
   on E: Exception do
    begin
     E.Message := 'Could Not Execute MS WORD!';
     raise;
    end;
  end;

Any help would be greatly appreciated thank you

Upvotes: 0

Views: 1232

Answers (1)

Rob Kennedy
Rob Kennedy

Reputation: 163247

KB 194306 demonstrates printing duplex using Word automation. The key is to insert a field, and then enter the printer-specific escape code to tell the printer to print in duplex mode. In Delphi, it might go something like this:

wrddoc.Selection.Fields.Add(wrddoc.Selection.Range, -1, 'PRINT 27 &l1S');

Then you can call Printout as normal to have Word print the document.

The article mentions that the escape code shown here is for HP printer drivers.

Upvotes: 1

Related Questions