I run pdf reports from Acrobat6. To change the pdf file name, set the caption using vba. My reports are by employee name, so I cycle through the records running the report once for each employee. In the loop in vba I set the caption equal to the employee's name. In the printer options for the report in design view, I specied for Acrobat NOT to prompt for file location, which causes it to go to the My Documents folder. I then had code to immediately move it from my documents to a path I had specified in a form. However, I later removed this because there were strange hangups with certain files (the move would fail and stop the whole process). Now I manually move the file from My Documents to the necessary network path using the "Send To any location" windows powertoy.
If your report name is standard, simply specify this name in the caption property.
The background processing is trickier. In print setup you can specify minimized (or hidden if I remember correctly), but my cursor still gets stolen from time to time. When you save changes to the report in design view, the print setting for that particular report are saved and passed to Adobe when the report is printed. There may be some way to tweak adobe into true background printing, but I haven't found it yet.
By [Reference], if you mean a parameter that is one of the fields in the dataset - this is very easy to do using ADO/DAO. Below is an example where a table containing a list of employees (run report once for each employee) contains a column "FullNamePDF" which is the employee name and some other stuff we want in the name. The report takes the parameter of [Employee] so I cycle through them all.
Public Function SalesRevisedRun() As String
Dim tst As New ADODB.Recordset
Set tst = New ADODB.Recordset
.Open "SELECT YourTable.[Employee], YourTable.[Full NamePDF] FROM YourTable", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'During diagnostics, enable the stop loop msgbox to avoid cycling through everything.
Do While Not .EOF 'And MsgBox("Stop Loop?", vbYesNo) = vbNo
DoCmd.OpenReport "Your Report", acViewPreview, , "[Employee]= " & """" & tst("Employee") & """" & ""
Reports![Your Report].Caption = Trim(tst("Full NamePDF"))
DoCmd.PrintOut acPrintAll, , , acHigh, 1, True
DoCmd.Close acReport, "Your Report"
I'm alright with Access, kinda average and I only understood a lil bit of that...
in response to your question, BOL is Bill of Lading, it is another document that gets printed along with the pickupsheet. [Reference#] is the number that we file by
So with that said I am trying to use Adobe Distiller and create PDFs that will automatically save to the proper folder with the name [Reference#].pdf for the pickupsheet and [Reference#]-BOL.pdf for the Bill of Lading.
Please help, the 1st is my deadline and this is my last portion of the program to do........
This is a report that you're printing to acrobat, right? If this is the case, my understanding is that you want to run the report once for each [reference] and print it to a file called BOL-[reference].pdf, right?
To do this, you'll need to cycle through each [reference] in the dataset - running BOL-[reference].pdf for each one.
Give me the parts of my previous post that you didn't understand and I'll clarify.
ok here is my deal... when setting up a pickup a [Reference#] is being assigned to the shipment, which is the primary key in my table, [Main]
when in forms!pickupsheet when done filling out the order our user has to print two reports, the first one named "pickupsheet" and the second named "Bill of Lading"
I am trying to create PDF backups to be stored on the server, to keep them filed correctly I would like for them to be named [Reference#].pdf (for "pickupsheet") and [Reference#]-BOL.pdf (for "Bill of Lading")
I have Adobe Professional, and I am trying to use Adobe Distiller to create the PDF through VBA and name the reports being saved in VBA.
So I need help with the code on how to select the printer(Distiller sets up a printer to create the PDF and prints to file) and then without the user doing anything save the created PDF in the proper folder and named properly.
First of all, go to each of these 2 reports in design view, and then to File | Page Setup and the Page tab. Click the "Use Specific Printer" radio button and then the "printer" button. In the next popup click the "Properties" button. On the Adobe PDF Settings tab, make sure only the 3rd and 2nd to last checkboxes are checked (do not send fonts & delete log files). Save each report to keep these settings.
Now these reports will automatically print a pdf to your My Documents folder.
From here - go back to my code in the earlier post and substitute your table/field values in.
I really thank you for your patience with me but I still am not understanding where it is saving to the name and directory that I am looking for with the code you supplied. This is going to be done each time a new pickup is created, and we are doing 10-20,000 moves a year thats why it's so imporatant that this be automated
I am trying to learn what the code means as well as get the job done... I don't want to be just pasting code into it not knowing what each part does
The code I provided does not move it from the My Documents folder. to do that you'd need to move it with vba inside your report loop with something like this (where "mynetwork\mypath\" is your preferred path:
infile = "C:\Documents and Settings\" & Environ("Username") & "\My Documents\"
outfile = \\MyNetwork\Mypath\"
'the following creates the pdf file
DoCmd.PrintOut acPrintAll, , , acHigh, 1, True
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(infile & file) Then
MsgBox infile & file & " does not exist!", vbExclamation, "Source File Missing"
ElseIf Not fso.FileExists(outfile & file) Then
fso.MoveFile (infile & file), outfile
MsgBox outfile & file & " already exists!", vbExclamation, "Destination File Exists"
As I mentioned, I was not happy with this code because it was kletchy. It would often lock up on files. I later added a 5 second pause function, thinking that the filesystem was trying to move the file before acrobat was finished writing to it. This cured everything but filenames that contained spaces - which would always hang the system up.