?
Solved

Set paperbin

Posted on 1998-07-07
5
Medium Priority
?
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
swilt earned 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 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