PDA

View Full Version : How to print multiple linked PDF Files from query result?



Ajz1971
10-11-2016, 07:43 AM
Hi There,
I’m not sure if I’m in the right section here? But what I’m looking for is a way to do the following…


I have a query that gives me a list of Linked PDF Files (C:/Policies/Policy1.PDF…. C:/Policies/Policy2.PDF etc…) what I would like to do is be able to print off all documents automatically using VBA code that I can attach to the on click of a button…Is this possible? :confused:

The query is named 'Staff Query'... The column of linked files is 'Feild2' ....I do not need to view the PDF's, and Adobe PDF reader path is "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"



Thanks in advance for any feedback :)

jonh
10-11-2016, 03:28 PM
quick search gives this
http://www.access-programmers.co.uk/forums/showthread.php?t=225836

so you might use something like...(not tested)

with currentdb.openrecordset("select feild2 from [staff query]")
do until .eof
Shell sAcrobatReaderExe & " /P " & Chr(34) & .fields(0) & Chr(34)
.movenext
loop
end with

Ajz1971
10-12-2016, 03:31 AM
Hi Jonh, thanks for the help :)

I have added this code to yours and it prints off the PDF's..."YAY"!!

the only problem is...
1- it opens acrobat reader in print view (you have to click print for each file)
2- Its not printing the PDF's off in sequence as listed in the query (row 1, row2, row3...etc)

Here is the code ...


Private Sub Command61_Click()
Dim sAcrobatReaderExe As String ' full path to the Acrobat reader executable
sAcrobatReaderExe = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
With CurrentDb.OpenRecordset("select field2 from [staff query]")
Do Until .EOF
Shell sAcrobatReaderExe & " /P " & Chr(34) & .Fields(0) & Chr(34)
.MoveNext
Loop
End With
End Sub

Any thoughts? ..... and again! Big thanks!:content:

jonh
10-12-2016, 09:37 AM
1) I've never used acrobat reader for anything so your guess is as good as mine.
Search google for 'acrobat reader command line'.

2) Try specifying the field to order by.
"select field2 from [staff query] order by [field to order by]"