user3271392
user3271392

Reputation: 147

How to change the active printer in MS word using delphi xe3

i open a MS Word document using the following code:

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

And print it using wrdapp.Printout

I have a combobox that has a list of printer names from the computer using the code:

Combobox32.Items.Assign(Printer.Printers);

How do i change the active printer in MS Word to the selected printer in the combobox, so that when i call wrdapp.Printout it will print from the printer selected in the combobox?

thank you in advance for your help.

Upvotes: 1

Views: 892

Answers (1)

fpiette
fpiette

Reputation: 12292

You can simply assing WrdApp.ActivePrinter with the name of the printer you want to use. In your case, you picjk it from the item selected in the combobox. For a code example, see this: http://francois-piette.blogspot.be/2014/02/automate-word-document-print-using.html

Upvotes: 1

Related Questions