将报告输出为PDF [英] Outputting reports as PDF

查看:43
本文介绍了将报告输出为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对VBA比较陌生,可以帮我一点!这听起来真的很长,我很抱歉,但我希望它会描绘出我想要做的事情。


基本上这就是我想要的执行:我希望表单(选择器)有4个复选框和一个运行命令按钮。当用户点击运行时,将出现另一个表单(ReportsMenu),提供各种选项。但重要的是,当用户单击确定(在ReportsMenu表单中)时,我希望(取决于在选择器表单中选中的复选框)将报告输出为pdf文件。代码当前以快照或富文本格式输出报告(取决于在ReportsMenu中检查哪个单选按钮)但他们更喜欢它,如果不是这样,它只是在单击确定时直接输出到PDF。


但是目前Selector表单有5个单选按钮(一个用于选择全部),因此用户只能选择4个选项中的全部或一个(这就是他们想要它的原因)有复选框,所以他们可以选择多个但不一定全部(我在选择器表单中更改))。问题(最终到达那里我很抱歉!!)是使用ReportsMenu表单。 ReportsMenu的原始代码非常混乱,因为我不熟悉VBA(也不是编写代码的人的逻辑),我不确定要更改哪些部分(以PDF格式打印) )以及将要离开的内容。 (我只是从头开始整个事情,但有一些链接到outlook的代码,我不确定是否会影响其他任何东西)


这是代码(它非常很抱歉):

Hi I''m relatively new to VBA and could really do with some help please!! This is going to sound really long winded i''m sorry but I hope it will paint a picture of what i''m trying to do.

Basically here is what I want to do: I want a form (Selector) to have 4 check boxes and a Run command button. When the user clicks run another form (ReportsMenu) will appear giving various options. Importantly though, when the user clicks OK (in the ReportsMenu form) I want (depending on which check boxes are checked in the Selector form) to output the reports as pdf files. The code currently outputs the reports as snapshot or rich text format (depending on which radio button is checked in ReportsMenu) but they would prefer it if instead of this it just outputted straight to PDF when OK was clicked.

However currently the Selector form has 5 radio buttons (one is used to select all) so the user can only select all or one of the 4 options (which is why they want it to have check boxes instead so they can pick more than one but not necessarily all (which I have changed in the Selector form)). The problem (eventually got there i''m sorry!!) is with the ReportsMenu form. The original code for the ReportsMenu is very messy and, as i''m not very familiar with VBA (nor with the logic of the person who wrote the code), i''m not sure which parts to change (to print as PDF) and what to leave as it is. (I would just start the whole thing from scratch but there is some code linked to outlook that im not sure affects anything else at all or not)

Here is the code (it is very long I apologise):

展开 | 选择 | Wrap | 行号

推荐答案

请查看此链接以了解打印输出对于PDF,我知道你只是在学习VBA,但你看起来很快就会把它拿起来,这应该会让你朝着正确的方向前进。

Lebans报告PDF格式


-AJ
Please look at this link about printing out to a PDF, I understand you are just learning VBA but you look like you are picking it up quickly and this should get you in the right direction.

Lebans Report to PDF

-AJ


如果您正在使用Access 2007年,打印到pdf简化为简单的一行命令:

If you''re using Access 2007, printing to a pdf is reduced to a simple one line command:

展开 | 选择 | Wrap < span class =codeDivider> | 行号


感谢您的链接ajalwaysus我现在就检查一下。
Thanks for the link ajalwaysus I will check it out now.

如果您使用的是Access 2007,打印到pdf会简化为简单的一行命令:


展开|选择|自动换行|行号DoCmd.OutputTo acReport,MyChoice,acF ormatPDF,c:\ &安培; MyReport& " .pdf",False,""

Access 2007 RTM& 2007 Service Pack 1要求您安装转换为PDF / XPS加载项。


Access 2007 Service Pack 2为转换添加了本机支持。


现在,将这一行添加到上面的例程中是一个棘手的部分。如果我有空的时间,没有其他人帮助你,我会重新审视代码并提出一些建议。但请告诉我们您和您的客户首先使用的版本。
If you''re using Access 2007, printing to a pdf is reduced to a simple one line command:

Expand|Select|Wrap|Line Numbers DoCmd.OutputTo acReport, MyChoice, acFormatPDF, "c:\" & MyReport & ".pdf", False, ""
Access 2007 RTM & 2007 Service Pack 1 require you have the Convert to PDF/XPS add-in installed.

Access 2007 Service Pack 2 adds native support for the conversions.

Now, adding this line into your routines above is the tricky part. If I have time later, and nobody else assists you, I''ll revisit the code and make some suggestions. But let us know which version you and your clients are using first.



谢谢你的伴侣。如果有帮助的话,我正在使用Access 2003吗?

Thank you mate. I''m using Access 2003 if that helps at all?


这篇关于将报告输出为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆