Jump to content
Sign in to follow this  

Print a document to a specific paperbin

Recommended Posts


I'm trying to print a document (pdf) to a printer, but I need to change the paperbin. I can print with adobe reader (commandline).

I searched this forum and saw the print udf, wich enabled me to change the default printer, but not the paperbin for a specific printer.

Through some goog'ling I found a code for VBA, and I wondered if this could be done with AutoIT

Private Declare Function DeviceCapabilities Lib "winspool.drv" Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, ByVal dev As Long) As Long

Function GetBinNames() As Variant

Dim iBins As Long

Dim ct As Long

Dim sNamesList As String

Dim sNextString As String

Dim sPort As String

Dim sCurrentPrinter As String

Dim vBins As Variant

'Get the printer & port name of the current printer

sPort = Trim$(Application.Printer.Port)

sCurrentPrinter = Trim$(Application.Printer.DeviceName)

'Find out how many printer bins there are

iBins = DeviceCapabilities(sCurrentPrinter, sPort, _

DC_BINS, ByVal vbNullString, 0)

'Set the string to the right size to hold all the bin names

'24 chars per name

sNamesList = String(24 * iBins, 0)

'Load the string with the bin names

iBins = DeviceCapabilities(sCurrentPrinter, sPort, _

DC_BINNAMES, ByVal sNamesList, 0)

'Set the array of bin names to the right size

ReDim vBins(0 To iBins - 1)

For ct = 0 To iBins - 1

'Get each bin name in turn and assign to the next item in the array

sNextString = Mid(sNamesList, 24 * ct + 1, 24)

vBins(ct) = Left(sNextString, InStr(1, sNextString, Chr(0)) - 1)

Next ct

'Return the array to the calling routine

GetBinNames = vBins

End Function

Share this post

Link to post
Share on other sites

I couldn't set the paperbin directly, so I've had to use the printui.dll and then set the drawer with the gui.

perhaps it could be done using the Canon Printer SDK(We have a canon printer, but we don't have the SDK).

Run ('rundll32 printui.dll,PrintUIEntry /e /n "' & $printername )
    WinWaitActive ( $printertitle , ""  )
    $ctrl = ControlGetHandle($printertitle,"","SysTabControl321")
    _GUICtrlTab_ClickTab($ctrl, 2, "left", False, 10);Tabbladnummer ° 2 ===
    WinWaitActive ( $printertitle , "Paper Source"  )
    ControlCommand($printertitle,"Paper Source","ListBox1","SelectString", $lade)
    ControlClick($printertitle,"Paper Source","Button17")
    ControlClick($printertitle,"Paper Source","Button15")

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.