主题:HP laserJet 9050dn 打印机设定纸槽失败
在调用HP laserJet 9050dn打印机的时候设定纸槽失败, 方法如下
我将所有的可能的打印机的纸槽全部设定到打印机中, 然后查看打印机的纸槽信息, 每次设定的代码如下
Private Sub Command1_Click()
On Error GoTo Err_Debug
Dim nPrinterTrayNo As Integer
strInfo = comPrinterTray.Text
nPrinterTrayNo = GetTrayInfo(strInfo)
Printer.PaperBin = nPrinterTrayNo
Debug.Print Printer.PaperBin
OutputLogFile "Set Ok and the printer paperbin = " & nPrinterTrayNo, "Set Printer PaperBin"
OutputLogFile "Set printer paperbin ok and get the value from printer = " & Printer.PaperBin, "Set Printer PaperBin"
Exit Sub
Err_Debug:
OutputLogFile "Set Failed and the printer paperbin = " & nPrinterTrayNo, "Set Printer PaperBin"
End Sub
Private Function GetTrayInfo(ByVal strInfo As String) As Integer
On Error GoTo Err_GetTrayInfo
Dim nIndex As Integer
nIndex = InStr(strInfo, "-")
If nIndex > 0 Then
GetTrayInfo = Mid(strInfo, nIndex + 1)
Else
GetTrayInfo = 0
End If
Exit Function
Err_GetTrayInfo:
OutputLogFile "Err.Desc = " & Err.Description, Err.Source
End Function
其中comPrinterTray是一个下拉列表, 其中添加了以下信息, 函数GetTrayInfo(strInfo)是从列表的text中获得具体的值
comPrinterTray.Clear
comPrinterTray.AddItem "crPRBinUpper -1"
comPrinterTray.AddItem "crPRBinLower -2"
comPrinterTray.AddItem "crPRBinMiddle -3"
comPrinterTray.AddItem "crPRBinManual -4"
comPrinterTray.AddItem "crPRBinEnvelope -5"
comPrinterTray.AddItem "crPRBinEnvManual -6"
comPrinterTray.AddItem "crPRBinAuto -7"
comPrinterTray.AddItem "crPRBinTractor -8"
comPrinterTray.AddItem "crPRBinSmallFmt -9"
comPrinterTray.AddItem "crPRBinLargeFmt -10"
comPrinterTray.AddItem "crPRBinLargeCapacity -11"
comPrinterTray.AddItem "crPRBinCassette -14"
comPrinterTray.AddItem "crPRBinFormSource -15"
但是设定以后只有15是成功的, 其他的全部失败, 请高手指点一二