Jump to content

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...