I recently purchased a Brother QL-570 label printer, unfortunately it doesn't operate when I try to use VBA samples provided by Brother:
Option Explicit
Const sPath = "C:\Temp\Asset2.lbx"
Private Sub cmdPrint_Click()
Dim bRet As Boolean
Dim ObjDoc As bpac.Document
Set ObjDoc = CreateObject("bpac.Document")
'Open lbx file
bRet = ObjDoc.Open(sPath)
If (bRet <> False) Then
' Determine how many rows the user selected
Dim iTotal As Integer
iTotal = Selection.Rows.Count
' Start Print
ObjDoc.StartPrint "", bpoDefault
Dim r As Integer
For r = 1 To iTotal
Dim Str As String
Dim iRow As Integer
'Data Text (Document)
iRow = Selection.Cells(r, 1).Row
Str = Cells(iRow, 1).Text
ObjDoc.GetObject("objDocument").Text = Str
'Data Text(Barcode)
ObjDoc.GetObject("objBarcode").Text = Str
'Data Text (Period)
Str = Cells(iRow, 2).Text
ObjDoc.GetObject("objPeriod").Text = Str
'Data Text (Management)
Str = Cells(iRow, 3).Text
ObjDoc.GetObject("objManagement").Text = Str
' Print
ObjDoc.PrintOut 1, bpoDefault
Next
' End Print
ObjDoc.EndPrint
' Close object
ObjDoc.Close
End If
End Sub
I've made sure to included the b-Pac reference library in Excel VBA.
I've also stepped through the code, no errors occur. Any suggestions on how I could get this to work?
Bookmarks