最近,似乎存在一些与打印机以及更改表单和报表的打印特征有关的问题。 仅出于这个原因,我决定将本周的技巧专门用于这些主题。 该提示实际上包括几个提示,我认为这些提示对所有用户(从新手到专家)都非常有用。 为了利用这些技巧中包含的代码,您必须具有Access 2002或更高版本。
- 如何生成可用打印机列表?
'Prints a list of available Printers and thier Ports 'to the Immediate Window Dim prn As Printer For Each prn In Application.Printers Debug.Print prn.DeviceName & " on " & prn.Port Next prn
- 如何找到当前窗口的默认打印机的特征?
'Lists specific characteristics of the Current Printer With Application.Printer Debug.Print "Current Printer : " & .DeviceName Debug.Print "Device Driver Name: " & .DriverName Debug.Print "Port Assignment : " & .Port End With
- 如何用已安装打印机列表填充组合框?
'Fills a Combo Box with a list of Installed Printers Dim prn As Printer, cbo As ComboBox Dim strText As String Set cbo = Me![cboPrinters] 'Clear the control's list. cbo.RowSource = vbNullString cbo.RowSourceType = "Value List" 'Set up three columns cbo.ColumnCount = 3 cbo.ColumnWidths = "3in;1in;1in" cbo.Width = 5 * 1440 '5 inches (measured in Twips) 'Bind to the DeviceName column (1) cbo.BoundColumn = 1 For Each prn In Application.Printers strText = prn.DeviceName & ";" & prn.DriverName & _ ";" & prn.Port cbo.AddItem strText Next prn
- 如何更改默认打印机?
'Changes the Default Printer, then resets it to the original Printer. 'This will only work if the report is set up to Print to the Default 'Printer Set Application.Printer = Application.Printers("Acrobat PDFWriter") DoCmd.OpenReport "<Your Report Name>", acViewNormal, , , acWindowNormal 'Reset the Default Printer back to the way it was Set Application.Printer = Nothing
- 如何将报告打印到特定设备?
'The following code will Print rptInvoices to the Acrobat PFDWriter Printer Dim rpt As Report DoCmd.OpenReport "rptInvoices", View:=acViewPreview, WindowMode:=acHidden Set rpt = Reports("rptInvoices") Set rpt.Printer = Application.Printers("Acrobat PFDWriter") DoCmd.OpenReport "rptInvoices" DoCmd.Close acReport, "rptInvoices"
- 如何修改表格或报表的打印机特性?
'Open rptInvoices in Design view, change 3 of its Properties 'Print the report, and then close the report. Const conReport As String = "rptInvoices" DoCmd.OpenReport conReport, View:=acViewPreview, WindowMode:=acHidden 'Force the printer to look to the upper bin for paper, print on 'Monarch-size envelopes, and Print two copies, set orientation to 'Landscape With Reports(conReport).Printer .PaperBin = acPRBNUpper .PaperSize = acPRPSEnvMonarch .Copies = 2 .Orientation = acPRORLandscape .Duplex = acPRDPVertical .PrintQuality = acPRPQMedium End With 'Now print the report. DoCmd.OpenReport conReport DoCmd.Close acReport, conReport
- 如何更改表单或报表的布局特征?
Const conReport As String = "rptInvoices" Const conTwipsPerInch As Long = 1440 DoCmd.OpenReport conReport, View:=acViewPreview, WindowMode:=acHidden 'Modify layout information. set up margins, columns, and 'print only data. With Reports(conReport).Printer .LeftMargin = 0.5 * conTwipsPerInch .RightMargin = 0.5 * conTwipsPerInch .TopMargin = 1 * conTwipsPerInch .BottomMargin = 1 * conTwipsPerInch .ItemsAcross = 2 .ItemLayout = acPRHorizontalColumnLayout .DefaultSize = False .ItemSizeWidth = 3 * conTwipsPerInch .ColumnSpacing = 0.1 * conTwipsPerInch .DataOnly = True End With DoCmd.OpenReport conReport DoCmd.Close acReport, conReport
From: https://bytes.com/topic/access/insights/738348-printer-printing-tips