在分配Application.ActivePrinter属性之前将Application.ScreenUpdating属性设置为False(以加快速度),并确保打印机名称正确。示例如下:
Sub printDocument()
Application.ScreenUpdating = False
On Error GoTo printError
Application.ActivePrinter = "\\print_server\printer_name"
Sheets("Sheet1").PrintOut
Application.ScreenUpdating = True
Exit Sub
printError:
MsgBox "Error assigning printer: " & Err.Number & " - " & Err.Description
Application.ScreenUpdating = True
End Sub