User Specified Printer


Posted by Zif on May 01, 2001 3:24 AM

Hiya

I have a multi-page spreadsheet that is opened and parts of it printed by different users over the network.

I've set up a macro that displays a userform giving the user the option of which worksheets to print, but I can't work out how to allow the user to specify which printer they want to send the output to.

Different areas have different printer names on the network, and these names have a tendancy to change every 3 months or so as our Network Department rotate and replace printers, so I can't just hard code the various printer options into the userform.

Is there any way that I can display a dialog box allowing the user to specify the network printer they wish to use and then using the specified printer to print one copy of all of the specified worksheets from the user form??


Zif :-)

Posted by Ivan Moala on May 01, 2001 5:50 AM

Zif To do this you will need to enumerate the printers.
For win NT this can be done via

Declare Function EnumPrinters Lib "winspool.drv" Alias "EnumPrintersA" (ByVal flags As Long, ByVal name As String, ByVal Level As Long, pPrinterEnum As Byte, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long

The EnumPrinters function for Win NT 3.1 or latter it enumerates available printers, print servers, domains, or print providers.

The routine is a bit long winded....if you like
I can send you an example of this. It uses userforms to enumerate the printers.


Ivan



Posted by Ivan Moala on May 01, 2001 5:56 AM

Or another way is to let the user select the printer via the Printer Control panel;
Try this;
Sub Printers()
Call Shell("rundll32.exe shell32.dll,Control_RunDLL main.cpl @2")
End Sub


Ivan