【发布时间】:2016-03-31 16:45:20
【问题描述】:
我正在尝试为表单上的打印机选择提供控件。
名为cbxPrinterList 的组合框列出了打印机名称。当用户单击Command1 按钮时,应从选定的打印机打印CompanyHistory 报告。我怎样才能强制它在横向打印。
以下代码运行良好,但有一个例外。该报告采用横向设计。但它是纵向打印的。
Private Sub Command1_Click()
Dim reportName As String
reportName = "CompanyHistory"
Dim vPrinter As Access.Printer
Set vPrinter = Application.Printers(cbxPrinterList.ListIndex)
vPrinter.Orientation = acPRORLandscape
DoCmd.OpenReport reportName, View:=acViewPreview, WindowMode:=acHidden
Set Reports(reportName).Printer = vPrinter
DoCmd.OpenReport reportName, View:=acViewNormal
Set Application.Printer = Nothing
' Close report without saving.
DoCmd.Close ObjectType:=acReport, ObjectName:="Invoice", Save:=acSaveNo
End Sub
【问题讨论】: