打印机和打印提示

最近,似乎存在一些与打印机以及更改表单和报表的打印特征有关的问题。 仅出于这个原因,我决定将本周的技巧专门用于这些主题。 该提示实际上包括几个提示,我认为这些提示对所有用户(从新手到专家)都非常有用。 为了利用这些技巧中包含的代码,您必须具有Access 2002或更高版本。

  1. 如何生成可用打印机列表?
    '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
  2. 如何找到当前窗口的默认打印机的特征?
    '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
  3. 如何用已安装打印机列表填充组合框?
    '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
  4. 如何更改默认打印机?
    '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
  5. 如何将报告打印到特定设备?
    '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"
  6. 如何修改表格或报表的打印机特性?
    '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
  7. 如何更改表单或报表的布局特征?
    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

V1.9 新增功能特性:1.增加了可拖动的自由打印对象。2.支持脚本对话框。3.支持内部数据报表参数报表(可以在报表中直接访问数据库定义SQL)。4.速度有很大提高(经测试至少提高30%),可以设置预览生成报表同步进行。5.支持自定义预览。 使用AcPreview控件可以定义自己的打印预览Form,也可以将数据预览放在同一个界面上。6.控件增加了PreviewOptons、PrintOptonsDesignOptions等几个属性。 可以设定设计窗口标题、预览窗口标题、预览方式、指定缺省预览缩放比例等。7.调用TAcReport.PrintFill方法可以进行套打。8.页眉页脚中支持表达式。9.支持背景图片。 执行菜单:"插入|插入北景图片"项可以使用此功能。10.编辑功能加强 例如:执行"表格|从文件装入...",可以将一个模板插入到当前页面、可以指定行高单元格宽度、可以按住 Shift + 方向键 对单元格大小进行微调等。11.控件新增了OnFunctionOnGetvalue两个事件,可以使用这两个事件定义自己的变量函数而不用使用函数库管理器。12.Demo有所增强。关于Anycell Report:基于表格的中国式报表组件,是一款中文化程度很高、最终用户容易学习的报表组件,操作简单方便、计算功能强大、支持表达式脚本、支持自定义SQL对话框。容易与程序集成及易于扩充。AC Report由100%的Delphi代码实现,支持分组、交叉表、子报表等复杂的报表,支持导入Excel、Rtf、html文档格式相关贴图设计界面:http://www.acreport.com/upload/images/design.pngdemo: http://www.acreport.com/upload/images/newdemo.png子报表:http://www.acreport.com/upload/images/new2.png对话框:http://www.acreport.com/upload/images/dlg1.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值