使用 vba 将多个访问报告合并到一个 pdf 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25402653/
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
Merge multiple access reports to one pdf file using vba
提问by Vinny
I wan't to merge multiple access reports to one pdf file using vba code. This vba code needs to work on the computers at my work. These computers only contain Adobe Reader, and I am not able to install Acrobat because I am not Administrator. So now my code generates for all the reports a seperate pdf. I had some code to merge these pdf files to one pdf file where I use 'Acrobat.CAcroApp'. But i get an error on line:
我不想使用 vba 代码将多个访问报告合并到一个 pdf 文件中。这个 vba 代码需要在我工作的计算机上工作。这些计算机只包含 Adobe Reader,我不能安装 Acrobat,因为我不是管理员。所以现在我的代码为所有报告生成一个单独的 pdf。我有一些代码可以将这些 pdf 文件合并到一个 pdf 文件中,我在其中使用了“Acrobat.CAcroApp”。但我在网上收到一个错误:
Set AcroApp = CreateObject("AcroExch.App")
I think I am not able to do this cause the computers only have Adobe Reader installed. Is there a possibility to create one pdf file for multiple reports/pdfs without using Acrobat.
我想我无法做到这一点,因为计算机只安装了 Adobe Reader。是否有可能在不使用 Acrobat 的情况下为多个报告/pdf 创建一个 pdf 文件。
Thx in advance
提前谢谢
采纳答案by Tom Collins
2 solutions.
2 解决方案。
- Make a master report that has each individual report embedded as a sub report. If it's just a few, it should work fine, but too many may bog down / crash the application.
- Here's a VBA way of doing it here.
- 制作一个主报告,将每个单独的报告作为子报告嵌入。如果只是几个,它应该可以正常工作,但是太多可能会使应用程序陷入困境/崩溃。
- 这是在此处执行此操作的 VBA 方式。
回答by Jens
Without acrobat reader this is indeed not going to work. I, however, am using the following dirty workaround for users without acrobat;
如果没有 acrobat 阅读器,这确实行不通。但是,我正在为没有 acrobat 的用户使用以下肮脏的解决方法;
Export all your reports to rich text ("*.RTF" format) in the same folder. Afterwards, you open a word application via access vba, and loop through the RTF files and then copy them into your word file, with a page break after every insert. Then, you save the word document as a .PDF file.
将所有报告导出为同一文件夹中的富文本(“*.RTF”格式)。然后,您通过访问 vba 打开一个 word 应用程序,并循环浏览 RTF 文件,然后将它们复制到您的 word 文件中,每次插入后都有一个分页符。然后,将 Word 文档另存为 .PDF 文件。
This is a method prone to errors, so if a more experienced user has a better way, please do tell. I'm interested as well!
这是一种容易出错的方法,所以如果有经验的用户有更好的方法,请告诉。我也有兴趣!