|
本帖最后由 andyzhaoda 于 2011-8-22 15:53 编辑
目前实现的方式为:
PrinterName = "Microsoft XPS Document Writer"
now_SaveFile = "报表1"
DoCmd.OpenReport now_SaveFile, acViewDesign , , , acHidden
Set rpt = Reports(now_SaveFile)
rpt.printer = access.Printers(PrinterName)
DoCmd.Close acReport, now_SaveFile, acSaveYes
DoCmd.OpenReport now_SaveFile, acViewPreview
Set rpt = Nothing
但是运行时发现问题:
access.Printers(PrinterName)返回的printer中,port都是一样的。所以,打印的时候报表所指向的打印机为实际port端口的打印机,
而并非所设置的打印机。
用
For Each prtLoop In Application.Printers
With prtLoop
debug.print "Device name: " & .DeviceName & vbCr _
& "Driver name: " & .DriverName & vbCr _
& "Port: " & .port
End With
Next prtLoop
实验。
结果为:
Device name: 发送至 OneNote 2010
Driver name: winspool
Port: USB010
Device name: Microsoft XPS Document Writer
Driver name: winspool
Port: USB010
Device name: Microsoft Office Document Image Writer
Driver name: winspool
Port: USB010
Device name: Fax
Driver name: winspool
Port: USB010
Device name: EPSON Stylus Photo R390 Series
Driver name: winspool
Port: USB010
Device name: Adobe PDF
Driver name: winspool
Port: USB010
Device name: \\pe4600\R390_3
Driver name: winspool
Port: USB010
Device name: \\PE4600\R390_7
Driver name: winspool
Port: USB010
Device name: \\pe4600\X-3000-2
Driver name: winspool
Port: USB010
Device name: \\PE4600\R390_1
Driver name: winspool
Port: USB010
Device name: \\PE4600\R390_4
Driver name: winspool
Port: USB010
Device name: \\PE4600\R290_3
Driver name: winspool
Port: USB010
Device name: \\pe4600\2100E_1
Driver name: winspool
Port: USB010
Device name: \\pe4600\X-3000-1
Driver name: winspool
Port: USB010
Device name: \\PE4600\R390_6
Driver name: winspool
Port: USB010
Device name: \\PE4600\R390_2
Driver name: winspool
Port: USB010
Device name: \\PE4600\R390_5
Driver name: winspool
Port: USB010
所有printer的port都指向了USB010。而usb010的实际打印机为\\PE4600\R390_4,则无论report.printer设成什么,都向\\PE4600\R390_4打印。
求高手赐教!!!
使用环境:
1、笔记本:win7+access2003
2、打印服务器:winserver2003+access2003
两者出现的情况一样。
|
|