Full Version: Setting printer properties
UtterAccess Forums > Microsoft® Access > Access Forms
jackheem
When I run the follow code to print the "Envelope" report it overrides the page setup settings for this report and pulls paper from the default bin and not from the manual feed as I have set it. I know i need to use the PaperBin property setting but I can't figure out where it goes inthe code below. Help.
im RptName As String
RptName = "Envelope"
DoCmd.OpenReport RptName, View:=acPreview, WindowMode:=acHidden
With Reports(RptName)
Set .Printer = Application.Printers(cboDestination.ListIndex)
'cboDestination.ListIndex is a listing of printers installed on the user's PC
End With
DoCmd.OpenReport RptName, View:=acViewNormal
DoCmd.Close acReport, RptName, acSaveNo
Kzin
The .paperbin property is part of the .printer object
Printer.Paperbin = acPRBNEnvManual
For Printer.Paperbin = acPRBNManual

If this doesn't work, then your papertray may not be enumerated to "standard" constants.

If this is the case, create a module, paste in this code and while the cursor is in the code block press that handy little play button.

CODE
Private Declare Function DeviceCapabilities Lib "winspool.drv" _
nbsp;  Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, _
   ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, _
   ByVal dev As Long) As Long
Private Const DC_BINS = 6
Private Const DC_BINNAMES = 12
Private Sub PrinterTesting()
   Dim prn As Printer
   Dim dwbins As Long
   Dim ct As Long
   Dim nameslist As String
   Dim nextString As String
   Dim numBin() As Integer
    Dim Text1 As String
    
   Text1 = ""
   For Each prn In Printers
        dwbins = DeviceCapabilities(prn.DeviceName, prn.Port, _
          DC_BINS, ByVal vbNullString, 0)
        ReDim numBin(1 To dwbins)
        nameslist = String(24 * dwbins, 0)
        dwbins = DeviceCapabilities(prn.DeviceName, prn.Port, _
          DC_BINS, numBin(1), 0)
        dwbins = DeviceCapabilities(prn.DeviceName, prn.Port, _
          DC_BINNAMES, ByVal nameslist, 0)
        If Text1 <> "" Then
           Text1 = Text1 & vbCrLf & vbCrLf
        End If
        Text1 = Text1 & prn.DeviceName
        For ct = 1 To dwbins
           nextString = Mid(nameslist, 24 * (ct - 1) + 1, 24)
           nextString = Left(nextString, InStr(1, nextString, _
             Chr(0)) - 1)
           nextString = String(6 - Len(CStr(numBin(ct))), " ") & _
           numBin(ct) & "  " & nextString
           Text1 = Text1 & vbCrLf & nextString
        Next ct
   Next prn
    MsgBox Text1
End Sub


Odont take credit for writing this code, just made some modifications. I dont know where it came from originally. What this will do is pop up a messagebox that displays all your printers and the constants for the paper trays on them.
However, if your papertray's constant is greater than 256, It wont actually work with the Application.Printer.PaperBin property, because that property is maxed at 256. Which is a problem that I am having with my HP LaserJet 4250TN, I need to print to the second tray, but the trays are enumerated 261 262.
So, I hope to have given you at least a couple of possibilities here... Let me know if any of them have worked for you.

Edited by: Kzin on Tue Nov 30 17:11:24 EST 2004.
Edited by: Kzin on Tue Nov 30 17:29:27 EST 2004.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.