0

I am trying to print a Serial Number to a Brother PT-D600 printer whenever an MS access form is submitted.

This is my current script.

Public Sub PrintLabel_Click(ByVal printStatement As String)
On Error GoTo ErrorHandler

    Dim labelmakerPath As String
    labelmakerPath = "C:\Program Files (x86)\Brother\Ptedit54\ptedit54.exe"
    
    Dim labelData As String
    labelData = printStatement
    
    Dim labelPath As String
    labelPath = "C:\Users\Username\Documents\My Labels\AutoLabel.lbx"
    
    Dim labelCommand As String
    labelCommand = """" & labelmakerPath & """" & " /X """ & labelData & """ """ & labelPath & """"
    
    Dim success As Integer
    success = Shell(labelCommand, vbNormalFocus)
    
    If success = 0 Then
        MsgBox "Error: Unable to run command: " & labelCommand, vbExclamation, "Error"
    End If
    
    Exit Sub

ErrorHandler:
MsgBox "An error occurred: " & Err.Description, vbExclamation, "Error"
End Sub

While trying to debug, I've tried to use the following python script to print directly from the command line


import subprocess

serialNumber = "20230219"
labelText = "1234567"

printerName = "Brother PT-D600"

printCommand = f'ptouch-printer -n "{printerName}" -l "24mm" -t "test label" -i "ABC" -s "{serialNumber}" -b "1" -q "1" "{labelText}"'

# Print the label

try:
subprocess.run(printCommand, shell=True, check=True)
print("Label printed successfully")
except subprocess.CalledProcessError as e:
print(f"Printing label failed: {e}")

However, it doesn't seem like ptouch-printer is available anymore?

  • 1
    What do you mean by "whenever an MS Access form is submitted"? How is a form submitted? What happens - error message, wrong result, nothing? What do you mean by "not available" - there are plenty of p-touch printer models. Where did you find this code and why do you think it can work in Access? – June7 Feb 20 '23 at 06:08

0 Answers0