通过VBA打印多个副本时,MS Access报告将打开导航窗格

时间:2013-07-15 18:25:15

标签: ms-access access-vba

我有报告我用来打印标签,一切正常,但报表打印时,导航窗格打开。我已将数据库选项设置为不显示导航窗格,除了此特定报告之外,它仍保持隐藏状态。这是我用来打印报告的VBA:

Dim intCopies as integer
intCopies = Me.txtCopies
DoCmd.SelectObject acReport, "rptShippingLabelTmo", True
DoCmd.PrintOut , , , , intCopies

报告设置为仅打印到特定打印机,我需要它才能打印多份副本而无需使用任何类型的对话框。 如何在不打开导航窗格的情况下打印报告?

2 个答案:

答案 0 :(得分:1)

第三个参数 InNavigationPane 表示是否应在数据库窗口(Access版本< = 2003)或导航窗格(Access> = 2007)中选择对象。使用False告知Access 在导航窗格中选择该报告,然后它不应显示导航窗格。

DoCmd.SelectObject acReport, "rptShippingLabelTmo", False

但是,如果报告尚未打开,请使用OpenReport代替SelectObject,然后使用Close

DoCmd.OpenReport "rptShippingLabelTmo", acViewPreview
'DoCmd.PrintOut , , , , intCopies
DoCmd.PrintOut Copies:=intCopies
DoCmd.Close acReport, "rptShippingLabelTmo"

答案 1 :(得分:0)

您可以每次隐藏窗格:

DoCmd.SelectObject acReport, "rptShippingLabelTmo", True
DoCmd.RunCommand acCmdWindowHide
DoCmd.PrintOut , , , , intCopies