2

我在 Access 中有一个 VBA 代码,可将 3 个单独的访问表单导出/保存到 PDF 以供记录。但是,完成后,Adobe Reader 会打开已保存的表单,要求处理器手动关闭所有 3 个表单。3 个表格听起来不多,但它们将为我们所有 239 个实体持续完成此过程!这意味着他们必须每天手动点击关闭超过 700 次!效率如此之高。

是否有用于在 Adob​​e Reader 中关闭 PDF 的 VBA 代码?

以下是我目前正在使用的代码:

Private Sub Command4_Click()
DoCmd.SetWarnings False

DoCmd.OpenQuery "Add to Completed", acViewNormal
DoCmd.OpenQuery "Clear from Master", acViewNormal
DoCmd.OpenQuery "Completed Totals", acViewNormal
DoCmd.OpenQuery "Update AB Totals", acViewNormal
DoCmd.OpenQuery "Update CD Totals", acViewNormal
DoCmd.OpenQuery "Update EF Totals", acViewNormal
DoCmd.OpenQuery "Update YTD Total", acViewNormal

DoCmd.OpenForm "Form123-pg1", acPreview
DoCmd.PrintOut acPrintAll
**DoCmd.OutputTo acOutputForm, "Form123-pg1", acFormatPDF, "Z:\Corporate\SubProcess\2014\" & Format(Date - 30, "mmyy") & " - " & [Forms]![Deal_Nav]![cbo_UnitNo] & " ReportName Pg1.pdf", True**
DoCmd.Close acForm, "Form123-pg1", acSaveNo
DoCmd.OpenForm "Form123-pg2", acPreview
DoCmd.PrintOut acPrintAll
**DoCmd.OutputTo acOutputForm, "Form123-pg2", acFormatPDF, "Z:\Corporate\SubProcess\2014\" & Format(Date - 30, "mmyy") & " - " & [Forms]![Deal_Nav]![cbo_UnitNo] & " ReportName Pg2.pdf", True**
DoCmd.Close acForm, "Form123-pg2", acSaveNo
DoCmd.OpenForm "Form123-pg3", acPreview
DoCmd.PrintOut acPrintAll
**DoCmd.OutputTo acOutputForm, "Form123-pg3", acFormatPDF, "Z:\Corporate\SubProcess\2014\" & Format(Date - 30, "mmyy") & " - " & [Forms]![Deal_Nav]![cbo_UnitNo] & " ReportName Pg3.pdf", True**
DoCmd.Close acForm, "Form123-pg3", acSaveNo

Me.Requery
Me.Refresh
DoCmd.SetWarnings True

结束子

4

1 回答 1

5

Acrobat 在创建 pdf 后打开,因为您告诉它这样做。

DoCmd.OutputTo acOutputForm, "Form123-pg1", acFormatPDF, "Z:\Corporate\SubProcess\2014\" & Format(Date - 30, "mmyy") & " - " & [Forms]![Deal_Nav]![cbo_UnitNo] & " ReportName Pg1.pdf", True

如果您将 AutoStart Flag 从 True 更改为 False,那么它不会,您也不必关闭任何东西。

DoCmd.OutputTo acOutputForm, "Form123-pg1", acFormatPDF, "Z:\Corporate\SubProcess\2014\" & Format(Date - 30, "mmyy") & " - " & [Forms]![Deal_Nav]![cbo_UnitNo] & " ReportName Pg1.pdf", False

现在Docmd.OutputTo 将只创建文件。

于 2014-10-23T15:22:35.500 回答