Creating a pdf as the output

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

We have macros that create and print out batches of works orders. We are
looking to e-mail the works orders to contractors rather than posting. This
means that instead of simply printing out the batch of works orders, we want
them to be created as indvidual pdf fiies which we can then digitally sign
and e-mail to the contractor.

Is there anyway within a macro command of sending the output to individual
pdf files rather than a printer output?
 
Stephen,

Outputting reports to PDF is simple, assuming you have a PDF writer
installed on your computer. In design view of the report, go to the
File|Page Setup menu, and under the Page tab, select Use Specific
Printer option, and nominate your PDF driver as the printer. You can
then use the OpenReport action in your macro, to output the report to PDF.

However, making them in a batch is more problematical, because it would
involve looping through the work order records, and looping type
processes are rather awkward to achieve using macros. Because of this,
it is easier to use a VBA procedure for this purpose. Your code would
look something like this...
Dim rst as DAO.Recordset
Set rst = CurrentDb.OpenRecordset("YourQuery")
Do Until rst.EOF
DoCmd.OpenReport "YourReport", , ,"WorkOrderID=" & rst!WorkOrderID
rst.MoveNext
Loop
rst.Close
Set rst = Nothing

.... where YourQuery is the name of a query that returns the work orders
in the batch to be printed, and WorkOrderID will be replaced by your WO
identifier.

The naming of the pdf files will need to be handled by your PDF writer.
Some drivers allow for the automatic incremental naming of files,
others to prompt the user for the file name at run time.

Alternatively, you may want to look at
http://www.lebans.com/reporttopdf.htm, but in this case, Stephen Lebans'
code does not support a Where Condition, so you would have to separately
code a looping of the SQL of the report's Record Source. But it does
give you control over naming the outputted PDF files.
 
Back
Top