Dynamic Output Filenames

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I've designed an Access macro to produce a series of
reports (130 different reports) ... each one is different -
based on the client - and I need to output these reports
as .pdf. The only problem: ... I need each report's
filename to be dynamic and fed by the macro.i.e. ...
report for userID 0143 ... needs a report output as pdf
with a filename '0143submit.pdf'. Presently ... I have to
manually save each report with a manually input filename.
Any ideas?
 
Brian:

How to do this depends a great deal on what PDF driver you are using to
output the file. If you are using Adobe Acrobat 5 or less, you can look
in the Acrobat SDK as to registry settings to use, if other drivers, consult
the writer of the driver.

If you don't want to take the time to code it all out yourself, then you
might look at our PDF and Mail Library for Access, which will allow you to
do this fairly easily. All you need to do is to loop through the recordset
that underlies your report to identify the User Ids to use to filter the
report and create the file name and then produce each file with code as
simple as:

Dim objPDF as New PDFClass
Const PDFENGINE_PDFWRITER =1
'Open a recordset hear of the distinct user IDs in the report
'Do until rs.EOF
With objPDF
.ReportName = "YourReport"
.ReportWhere = "UserID = " & 143 'or rs!somefield
.OutputFile = "c:\some dir\" & rs!somefield & "submit.pdf"
.PDFEngine = PDFENGINE_PDFWRITER
.PrintImage
End With
'rs.MoveNext
'Loop

That's about all there is to it. The library supports multiple PDF drivers
if you are using something other than Acrobat.

You'll find it on our web.

HTH
 
Back
Top