我一直在处理一个宏,它需要打印到标签打印机,而不是网络打印机。无论我怎么尝试,它都拒绝从默认打印机切换到标签打印机。
请看一下下面的代码,如果你看到任何错误,请告诉我:
Private Sub CommandButton2_Click()
Dim Box As String
Box = MsgBox("Are you sure you want to print this label " _
& "?", vbQuestion + vbYesNo)
If Box = vbNo Then
Exit Sub
Else: ThisWorkbook.Worksheets("Label").PrintOut ActivePrinter:="MSP-Label2 on msp-dc-001"
End If
End Sub谢谢!
发布于 2018-09-06 04:32:42
尝试让您的用户选择打印机,看看是否有效:
Private Sub CommandButton2_Click()
Dim box As String
box = MsgBox("Are you sure you want to print this label?", vbQuestion + vbYesNo)
If box = vbNo Then
Exit Sub
Else
If Application.Dialogs(xlDialogPrinterSetup).Show = False Then Exit Sub
ThisWorkbook.Worksheets("Label").PrintOut Copies:=1
End If
End Sub发布于 2018-09-06 04:56:39
我终于想通了!以下代码起作用了:
Private Sub CommandButton1_Click()
Dim Box As String
Box = MsgBox("Are you sure you want to print this label " _
& "?", vbQuestion + vbYesNo)
If Box = vbNo Then
Exit Sub
Else: ThisWorkbook.Worksheets("Label").PrintOut ActivePrinter:="\\msp-dc-001\MSP-Label2 on Ne07"
End If
End Subhttps://stackoverflow.com/questions/52191446
复制相似问题