从 Microsoft Excel 打印数据矩阵

Printing Data Matrix from Microsoft Excel

提问人:St3althPatchin 提问时间:7/13/2023 最后编辑:St3althPatchin 更新时间:7/13/2023 访问量:64

问:

我目前正在使用 vba 宏来收集用户的信息并将其用于数据矩阵。目前,代码的设置是宏收集信息,将其存储在 Excel 工作表中的单元格中,然后使用存储的信息发送到 P-touch Editor,创建并打印包含给定信息的数据矩阵。不幸的是,我还没有能够完全做到这一点。在我开始尝试处理这个问题之前,我还没有亲自写过所有这些内容。我搜索了其他论坛,但找不到类似的问题,或任何可能适用的解决方案。

在测试一些可以创建数据矩阵并将其打印在 Brother 打印机上的 vba 时,我反而收到了一条错误消息。然后我被告知打印机无法打印超出打印机可以打印的测量范围的内容。但我不熟悉我在代码中在哪里证实了这一点。

当我运行和测试时,我从打印机收到一条消息,指出:“机器中安装的磁带盒与应用程序中选择的类型不匹配。单击 (详细信息...) 以获得进一步的帮助。标签:1 1/2“ 打印机:1” 层压。

Sub PrintToSpecificPrinter( _
    ByVal ObjectToPrint As Object, _
    ByVal PrinterName As String _
)
    Dim sCurrentPrinter As String
  
    sCurrentPrinter = GetActivePrinter
    If SetDefaultPrinter(PrinterName) Then
        ObjectToPrint.PrintOut
        Call SetDefaultPrinter(sCurrentPrinter)
    Else
        MsgBox "Printing failed.", vbCritical
    End If

End Sub

Private Function GetActivePrinter() As String
    Dim sBuffer As String * 128, lBuffSize As Long
    lBuffSize = 128
    If GetDefaultPrinter(sBuffer, lBuffSize) Then
        GetActivePrinter = Left(sBuffer, lBuffSize - 1)
    End If
End Function


Sub PrintAddress()
    PrintToSpecificPrinter ObjectToPrint:=Range("A11:E19"), PrinterName:="Brother PT-9800PCN"
End Sub
Excel VBA 打印 SDK 兄弟 BPAC

评论

0赞 taller 7/13/2023
我猜您正在使用 Brother 标签打印机。希望对您有所帮助。stackoverflow.com/questions/27939513/......
0赞 St3althPatchin 7/13/2023
谢谢,我会寻找并希望得到答案。是的,我正在尝试使用的打印机是 Brother PT-9800 PCN。

答: 暂无答案