Access VBA - 将 Access 表单导出为 PDF,然后关闭 Adobe Reader
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26518833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Access VBA - Export Access Form to PDF then Close the Adobe Reader
提问by Grrly
I have a VBA code in Access that exports/saves 3 seperate Access Forms to a PDF for record purposes. However, upon completion, Adobe Reader opens the Forms that were saved, requiring the processor to manually close all 3 forms. 3 forms doesn't sound like much but they will be completing this process continuously for all 239 of our entities! This means they will have to manually click Close over 700 times a day! So much for efficiency.
我在 Access 中有一个 VBA 代码,可以将 3 个单独的访问表单导出/保存到 PDF 以供记录。但是,完成后,Adobe Reader 会打开已保存的表单,要求处理器手动关闭所有 3 个表单。3 种形式听起来并不多,但它们将持续为我们所有 239 个实体完成此过程!这意味着他们每天必须手动点击关闭超过 700 次!效率如此之高。
Is there a VBA code to close the PDF in Adobe Reader?
是否有用于在 Adobe Reader 中关闭 PDF 的 VBA 代码?
Below is the code that I am currently using:
以下是我目前使用的代码:
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\SubProcess14\" & 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\SubProcess14\" & 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\SubProcess14\" & 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
End Sub
结束子
回答by RudiBoy
Acrobat opens after creating your pdf because you tell it to.
Acrobat 在创建您的 pdf 后打开,因为您告诉它。
DoCmd.OutputTo acOutputForm, "Form123-pg1", acFormatPDF, "Z:\Corporate\SubProcess14\" & Format(Date - 30, "mmyy") & " - " & [Forms]![Deal_Nav]![cbo_UnitNo] & " ReportName Pg1.pdf", True
If you change the AutoStart Flag from True to False then it won't and you don't have to close anything.
如果您将 AutoStart Flag 从 True 更改为 False 那么它不会并且您不必关闭任何东西。
DoCmd.OutputTo acOutputForm, "Form123-pg1", acFormatPDF, "Z:\Corporate\SubProcess14\" & Format(Date - 30, "mmyy") & " - " & [Forms]![Deal_Nav]![cbo_UnitNo] & " ReportName Pg1.pdf", False
Now Docmd.OutputTo
will just create the file.
现在Docmd.OutputTo
将只创建文件。