‘get printer name again
strPrinterName = rpt.printer.DeviceName
Debug.Print strPrinterName
'close and save
DoCmd.Close acReport, strReport, acSaveYes
'open report again to see if new printer was saved
DoCmd.OpenReport ReportName:=strReport, View:=acViewDesign, WindowMode:=acHidden
Set rpt = Reports(strReport)
'get the current printer device name
strPrinterName = rpt.printer.DeviceName
Debug.Print strPrinterName
DoCmd.Close acReport, strReport, acSaveNo
=====================
IMMEDIATE WINDOW
Printer1
Printer2
Printer1
或切换打印机
Sub SwitchPrinter()
Dim prt As Printer
' Get current default printer
Set prt = Application.Printer
' Set default printer
Application.Printer = Application.Printers("OtherPrinter")
' Print something, e.g.
DoCmd.PrintOut
' Restore original printer
Set Application.Printer = prt
End Sub
或列出所有打印机
Sub ListPrinters()
Dim prt As Printer
For Each prt In Printers
Debug.Print prt.DeviceName
Next prt
End Sub 作者: tmtony 时间: 2017-6-3 11:44
如果你不想自己代码控制,可以直接调用 Access内置的打印设置窗口