【问题标题】:How to change the active printer in MS word using delphi xe3如何使用delphi xe3更改MS word中的活动打印机
【发布时间】:2014-02-26 04:25:36
【问题描述】:

我使用以下代码打开一个 MS Word 文档:

  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;

然后使用wrdapp.Printout打印出来

我有一个组合框,其中包含使用代码的计算机中的打印机名称列表:

Combobox32.Items.Assign(Printer.Printers);

如何将 MS Word 中的活动打印机更改为组合框中选定的打印机,以便当我调用 wrdapp.Printout 时,它将从组合框中选定的打印机打印?

提前感谢您的帮助。

【问题讨论】:

标签: delphi printing ms-word


【解决方案1】:

您可以简单地为 WrdApp.ActivePrinter 分配您要使用的打印机的名称。在您的情况下,您从组合框中选择的项目中选择它。 有关代码示例,请参见:http://francois-piette.blogspot.be/2014/02/automate-word-document-print-using.html

【讨论】:

  • 太好了,非常感谢。我之前确实尝试过类似的代码,但一直出错。我不知道为什么这行得通而另一个没有,但是谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-20
  • 2015-01-26
相关资源
最近更新 更多