![设置打印机 Excel vba 宏](https://linux22.com/image/1486889/%E8%AE%BE%E7%BD%AE%E6%89%93%E5%8D%B0%E6%9C%BA%20Excel%20vba%20%E5%AE%8F.png)
我正在尝试通过宏打印到同事电脑上的共享打印机。
我尝试了以下方法,但无济于事
Sub Tag()
ActiveCell.Resize(1, 1).Copy Worksheets("Sheet1").Range("A1")
ActiveCell.Offset(, 1).Resize(1, 1).Copy Worksheets("Sheet1").Range("A2")
'Worksheet("Sheet1").Range("A1:A2").Borders.LineStyle = xlNone
Sheets("Sheet1").Select
Range("A1:A2").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Worksheets("Sheet1").Range("A2").WrapText = True
Worksheets("Sheet1").Range("A2").Font.Size = 44
Worksheets("Sheet1").Range("A2").ShrinkToFit = True
Application.ActivePrinter = "Microsoft XPS Document Writer on XPSPort"
'Worksheets("Sheet1").PrintOut ActivePrinter = "DYMO LabelWriter 450 (Copy2) on JCSP55J"
End Sub
JCSP55J 是同事的网络名称。
请问有什么办法可以解决这个问题吗?
答案1
您可以将 ActivePrinter 作为参数添加到 PrintOut。
例如:
Worksheets("Sheet1").PrintOut ActivePrinter:="DYMO LabelWriter 450 (Copy2) on JCSP55J"
答案2
我是通过寻找这篇文章的功能找到解决方案的
Worksheets("[Sheet Where you wanna print]").PrintOut ActivePrinter:="[printer network route]"
如果你输入计算机的 IP 地址 \ 打印机的简称,效果会更好