我有一些代码,我认为应该打印给我的兄弟打印机,但似乎什么也没做。这让我很生气!
任何想法都可以
Dim PrinterName As String = ComboBox1.Text
If PrinterName.Contains("Brother") Then
Dim objDoc As bpac.Document
objDoc = CreateObject("bpac.Document")
Dim STRlbl As String = "C:\BarcodeScans\Application\Label.lbx"
If (objDoc.Open("C:\BarcodeScans\Application\Label.lbx")) Then
objDoc.GetObject("objCompany").Text = Txtbox1.Text
objDoc.GetObject("objName").Text = Txtbox2.Text
objDoc.SetPrinter(PrinterName, True)
objDoc.StartPrint(STRlbl, PrintOptionConstants.bpoDefault)
objDoc.PrintOut(1, PrintOptionConstants.bpoDefault)
objDoc.EndPrint()
objDoc.Close()
End If
它没有失败或错误,按照应该的步骤遍历每一行,它只是不打印。 标签/模板可以通过usb直接连接到Brother打印机的PC上打印。打印机是PT-9700PC
我很难过。
答案 0 :(得分:0)
Imports bpac
Imports System.Drawing.Printing
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim pkInstalledPrinters As String
' Find all printers installed
For Each pkInstalledPrinters In _
PrinterSettings.InstalledPrinters
ComboBox1.Items.Add(pkInstalledPrinters)
Next pkInstalledPrinters
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim PrinterName As String = ComboBox1.Text
Debug.Print(PrinterName.ToString)
If PrinterName.Contains("Brother") Then
Dim objDoc As bpac.Document
objDoc = CreateObject("bpac.Document")
Dim STRlbl As String = "C:\Users\...\UPC-A.lbx"
If (objDoc.Open(STRlbl)) Then
objDoc.GetObject("tUPC-A").Text = TxtBox1.Text
objDoc.GetObject("tRetail").Text = TxtBox2.Text
objDoc.GetObject("tBarCode").Text = TxtBox3.Text
objDoc.SetPrinter(PrinterName, True)
objDoc.StartPrint(STRlbl, PrintOptionConstants.bpoDefault)
objDoc.PrintOut(1, PrintOptionConstants.bpoDefault)
objDoc.EndPrint()
objDoc.Close()
End If
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text <> "" Then
Button1.Enabled = True
End If
End Sub
End Class