Solved

Set paperbin

Posted on 1998-07-07
5
206 Views
Last Modified: 2009-12-16
I can get the number and names of the available paperbin
with the DeviceCapabilities-api, but how can I set a
paperbin (using api-calls)
0
Comment
Question by:ga
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
swilt earned 100 total points
ID: 1465137
Bins and Trays (Tested using a HP5si)

Declare Function Escape Lib "gdi32" (ByVal hdc As Long, ByVal nEscape As Long, ByVal nCount As Long, ByVal lpInData As String, lpOutData As Any) As Long

Private Function PaperSource(ByVal nTray As Integer) As Integer
    'Values for nTray
    ' 0 Print/eject page
    ' 1 Tray 2
    ' 2 Manual feed paper
    ' 3 Manual feed envelope
    ' 4 Tray 3
    ' 5 Tray 4 (2000 sheet)
    ' 6 envelope feeder
    ' 7 Auto select tray
    ' 8 Tray 1
    PaperSource = EscapePrinter(nTray, "H")
End Function

Private Function PaperDest(ByVal nTray As Integer) As Boolean
    'Values for nBin
    ' 0 Auto select bin
    ' 1 Top bin (Face down)
    ' 2 Top bin (Face up)
    ' 3 Side bin
    ' 4 Mailbox bin 1
    ' 5 Mailbox bin 2
    ' 6 Mailbox bin 3
    ' 7 Mailbox bin 4
    ' 8 Mailbox bin 5
    ' 9 Stitcher bin
    PaperDest = EscapePrinter(nTray, "G")
End Function

Private Function EscapePrinter(ByVal nNum As Integer, ByVal sChar As String) As Boolean
    Const PASSTHROUGH = 19
   
    Dim sPcl As String, ret As Integer
   
    sPcl = Chr$(27) & "&l" & Trim$(nNum) & sChar
    sPcl = Chr$(Len(sPcl) Mod 256) & Chr$(Len(sPcl) \ 256) & sPcl
    Printer.Print
    ret = Escape(Printer.hdc, PASSTHROUGH, 0, sPcl, 0&)
    Printer.CurrentY = 0
    EscapePrinter = (ret > 0)
End Function


0
 

Author Comment

by:ga
ID: 1465138
This code doesn't work on my printer (HP 4si mx)
the returnvalue of the escape-api = -1
am i doing something wrong (is this code suiteble for any printer)
is there an other way to solve this problem ?

0
 
LVL 2

Expert Comment

by:swilt
ID: 1465139
http://www.micronet.fr/~okaczmar/q96795.htm
This is the place where I got the info from to write the code. You will notice I have modified the code a bit (from 16 to 32 bit). With your printer manual, this code and my code you should be able to work it out, if not leave a note and I will have another look.

The problem will be in the sPCL string (look at printer escape code in your manual)

And of course;
If the printer driver does not support the PASSTHROUGH printer escape, you must use the DeviceCapabilities() and ExtDevMode() functions instead.
0
 

Author Comment

by:ga
ID: 1465140
What I want is that the code is suiteble for any printer
When I use the DeviceCapabilities-api, I can get a list with
the available paperbins, but I don't know how to select one

0
 
LVL 2

Expert Comment

by:swilt
ID: 1465141
This gave me a value of 5 for Escape

PaperDest 1
Printer.Print "Hello"
Printer.EndDoc

Why don't you want to use Printer.PaperBin ?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now