打印到.pdf并使用特定文件名保存

时间:2016-05-03 13:43:47

标签: ms-access pdf access-vba

我想使用报告打印出.pdf查询的所有记录。我有超过1k的记录,并希望将每条记录保存为.pdf。我在查询中连接了字段“filename”,目的是使用“filename”字段保存报告。最终结果是单击“打印”按钮?数据库将打印到.pdf每条记录,并根据“文件名”字段保存文件。

我只是不知道怎么写vba。

报告:TEMP-Print-CHECKLIST 查询:TEMP-Print 保存到:C:\ Users \ mabanes \ Desktop \ TC

我从哪里开始?

1 个答案:

答案 0 :(得分:0)

Dim rs as ADODB.Recordset

rs.Open "TEMP-Print",CurrentProject.Connection

Do While Not rs.Eof
     'somehow either edit the query here so that the report only takes the record you need for the particular PDF file
     DoCmd.OutputTo acOutputReport, "TEMP-Print-CHECKLIST", acFormatPDF, " C:\Users\mabanes\Desktop\TC\" & rs.Fields("filename") & ".pdf", False
     rs.MoveNext    
Loop
相关问题