问题描述
我有以下的自动化code:
lPrintSetup:= fWordObject.Application.Dialogs.Item(wdDialogFilePrintSetup);
lPrintSetup.Printer:='MyPrinter';
lPrintSetup.DoNotSetAsSysDefault:= TRUE;
lPrintSetup.Execute;
lPrintSetup:= NULL;
的打印机
属性给我一些问题,有时执行
崩溃与EOleException(0x800A1460(错误code 5216):有,因为一个错误的PrinterName的打印机错误)
我有,我用EnumPrinters API调用获得 _PRINTER_INFO_2
记录所有打印机的打印机信息。我怎样才能谱写正确的PrinterName的Word中所提出的 _PRINTER_INFO_2
记录的信息?它至少有Windows 2000中,Word 2000和思杰工作。
一些背景资料:
我们的应用程序先用自我构建的PrinterName充满了PRINTERNAME。这给了与Citrix客户端的问题,所以对于Citrix客户端,我们采取了 _PRINTER_INFO_2.pPortName
并删除了客户端:#:一部分。
这是致力于为广大客户,但有时仍是打印机错误显示出来。
我至今尝试过(在Windows XP SP3,Word 2007中):
- 只取
_PRINTER_INFO_2.pPrinterName
。问题是,当你修改的目的printernames(重命名的PDFCreator到HP DESKJET 520 MYPC')崩溃对后者(同时选择在Word中这台打印机的工作原理)。 - 撰写这样的PrinterName的:
lPrintSetup.Printer:= PRINTER_INFO_2.pPrinterName +'在'+ PRINTER_INFO_2.pPortname
。似乎总是工作!但是,围绕谷歌搜索显示,上是本地化的,所以我不知道这是怎么回事在非英语的Windows版本。 修改:并不总是工作:(
另一种解决方案,我发现网站:
当从Word阅读的PrinterName它具有PRINTERNAME上Ne01:形式,其中Ne01从Ne00范围:到Ne99 :.该解决方案建议采取PrinterName的,只是尝试设置它,而从Ne00循环:到Ne99 :.当.Execute不会崩溃,你有正确的。我不是很喜欢这种试错的方法。
我想通了。 Word有在形式的PrinterNamePRINTERNAME上NE01。 Ne01:是在WIN.INI 的设备部分指定的printerport。所以现在我撰写的PrinterName为 这是远优于求助于我的问题中提到的线索和错误的方法。 I have the following automation code: The I have printer information of all printers in a Some background info: Our application first filled the Printername with a self constructed printername. This gave problems with Citrix clients, so for Citrix clients we took the What I have tried so far (on Windows XP SP3, Word 2007): Another solution I found on the web: When reading the printername from Word it has the form of "Printername on Ne01:", where Ne01 is ranged from Ne00: to Ne99:. The solution suggested taking the printername and just try to set it while looping from Ne00: to Ne99:. When .Execute doesn't crash, you've got the right one. I'm not very fond of this 'trail and error' method. I figured it out. Word has the printername in the form of "Printername on NE01:". Ne01: is the printerport as specified in the devices section of win.ini. So now I compose the printername as This is much better than to resort to the trail-and-error method mentioned in my question. 这篇关于通过自动化设置正确的打印机在MS Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! _PRINTER_INFO_2.pPrinterName'上'+ LT +; PrinterPort从WIN.INI>
并为FilePrintSetup对话框的打印机属性设置名称lPrintSetup := fWordObject.Application.Dialogs.Item(wdDialogFilePrintSetup);
lPrintSetup.Printer := 'MyPrinter';
lPrintSetup.DoNotSetAsSysDefault := True;
lPrintSetup.Execute;
lPrintSetup := Null;
Printer
property is giving me some problems, sometimes Execute
crashes with an EOleException (0x800A1460 (error code 5216): There is a printer error) because of a wrong printername._PRINTER_INFO_2
record which I obtained by a EnumPrinters API-call. How can I compose the right printername for Word given the information in a _PRINTER_INFO_2
record? It has work with at least Windows 2000, Word 2000 and Citrix._PRINTER_INFO_2.pPortName
and deleted the Client:#: part.This is working for the majority of our customers, but sometimes still the printer error shows up._PRINTER_INFO_2.pPrinterName
. Problem is that when you modify printernames on purpose (renaming 'PDFCreator' to 'HP DESKJET 520 on MYPC') it crashes on the latter (while selecting this printer in Word works).lPrintSetup.Printer := PRINTER_INFO_2.pPrinterName + ' on ' + PRINTER_INFO_2.pPortname
. Seems to work always! But googling around showed that ' on ' is localized, so I'm not sure if that's going to work on non-english Windows versions. Edit: does not work always :(_PRINTER_INFO_2.pPrinterName + ' on ' + <PrinterPort from win.ini>
and set that name for the printer property of the FilePrintSetup dialog.