Quantcast
Channel: VBForums - Reporting
Viewing all articles
Browse latest Browse all 594

Code to automatically do "Save As..." when creating a PDF document

$
0
0
Hi, I’m brand new on this forum and know only the bare rudiments of VBA, so please be gentle, and explain things in idiot language :)

I have some code in Access 2010 which runs various queries and then opens a report. The last steps of this code set my printer to CutePDF and then “prints” the report. Because CutePDF is a PDF writer, the Save As dialog box is displayed, which allows me to give the PDF file a name. So far so good.

But I need to do this 30+ times, each time using a different entry in my table as a parameter, a bit like having 30 customers. Assuming that I wanted to save the files in the same folder each time, overwriting the previous ones, how can I use code to say something like the following?

Code:

X = CountOf([NameOfEntry]) from “MyTable”

For N = 1 to X
  Read [NameOfEntry] from “MyTable”
    ‘Run the various queries          - I can do this part!
    ‘Print the report to PDF            - and this part!
  Save As..C:\Desktop\Reports\[NameOfEntry]; Overwrite = Yes
Next N

Obviously this code is not written correctly, but I hope it explains the logic of what I’m trying to achieve. I’m using Access 2010 on Windows XP Professional, if that makes any difference.

Thank you

Viewing all articles
Browse latest Browse all 594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>