T
Toh Sain
I am using Excel 2000 VBA.
Following Microsoft's Knowledge Base article 166008, I can enumerate the
networked printers on my client's XP system using PRINTER_INFO_1 and the
Win32 API EnumPrinters.
See http://support.microsoft.com/default.aspx?scid=kb;EN-US;166008
The problem is that I can't set Application.ActivePrinter to the printers that
are returned by EnumPrinters, correct though they are. This is because
Application.ActivePrinter requires printers named in the form
'<PrinterName> ON <PrinterPort>' and EnumPrinters does not return the
printer port for networked printers.
While recording a macro, I selected all of the printers, and I see a list
of printers such as the following:
"\\Server1Name\HP LaserJet 8000 Series PS on Ne01:"
"\\Server1Name\Xerox Phaser 7700DN on Ne02:"
"\\Server2Name\HP Color LaserJet 8500 on Ne03:"
EnumPrinters never returns the "Ne0?:" portion of these required strings. So
how can I write a function to create the correct strings?
(As a workaround, I have created an .INI file and handwritten all of the
available printers in it, from the macro. I read the .INI file instead of
calling EnumPrinters to populate my drop-down list of available printers.)
Following Microsoft's Knowledge Base article 166008, I can enumerate the
networked printers on my client's XP system using PRINTER_INFO_1 and the
Win32 API EnumPrinters.
See http://support.microsoft.com/default.aspx?scid=kb;EN-US;166008
The problem is that I can't set Application.ActivePrinter to the printers that
are returned by EnumPrinters, correct though they are. This is because
Application.ActivePrinter requires printers named in the form
'<PrinterName> ON <PrinterPort>' and EnumPrinters does not return the
printer port for networked printers.
While recording a macro, I selected all of the printers, and I see a list
of printers such as the following:
"\\Server1Name\HP LaserJet 8000 Series PS on Ne01:"
"\\Server1Name\Xerox Phaser 7700DN on Ne02:"
"\\Server2Name\HP Color LaserJet 8500 on Ne03:"
EnumPrinters never returns the "Ne0?:" portion of these required strings. So
how can I write a function to create the correct strings?
(As a workaround, I have created an .INI file and handwritten all of the
available printers in it, from the macro. I read the .INI file instead of
calling EnumPrinters to populate my drop-down list of available printers.)