Reputation: 25
I am currently working with a vba macro to gather information from a user and use it in a data matrix. Currently the code is set up where the macro gathers the information, stores it on a cell in an excel sheet, and then uses the information stored to send to P-touch Editor, creating and printing the data matrix with the given information. Unfortunately, I haven't been able to completely achieve this. I haven't personally written all of this as it was done before I started trying to work with this issue. I've searched other forums and haven't been able to find a similar issue, or any resolution that could apply.
Upon testing some vba that would create the data matrix and print it on the Brother Printer, I'm instead greeted with an error message. I'm then told that the printer cannot print something that is out of the range for the measurements the printer can print. But I'm not familiar where I substantiated this in the code.
When I run and test, I get a message from the printer stating: "The tape cassette installed in the machine does not match the type selected in the application. Click (Details...) for further assistance. Label: 1 1/2" Printer: 1" Laminated."
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
Upvotes: 0
Views: 260