Need access vba to print all pdf files in folder

Just need code to print all .pdf files generated to folder.  How could I add that feature to not only print to file but also print out individual reports?

Sub PDFtoFileDentalReports()

    Dim db As DAO.Database
    Dim RS As DAO.Recordset
    Dim MyFileName As String
    Dim mypath As String
    Dim temp As String

        mypath = "C:\Users\u347867\Desktop\PrinttoPDF\DENTAL\"

        Set db = CurrentDb()

        Set RS = db.OpenRecordset("SELECT [Producer_Number] FROM [qdr_RDC_DENTAL]")

    Do While Not RS.EOF

        temp = RS("Producer_Number")

            MyFileName = RS("Producer_Number") & ".PDF"

        DoCmd.OpenReport "r_RDC_2015_DENTAL_SALES_BONUS", acViewReport, , "[Producer_Number]='" & temp & "'"

DoCmd.OutputTo acOutputReport, "r_RDC_2015_DENTAL_SALES_BONUS", acFormatPDF, mypath & "RDC_2015_DENTAL_SALES_BONUS_" & MyFileName

DoCmd.Close acReport, "r_RDC_2015_DENTAL_SALES_BONUS"
DoEvents
RS.MoveNext
Loop

RS.Close
Set RS = Nothing
Set db = Nothing

    'MsgBox "2015 RDC Health Sales Bonus Report Printout Complete", vbOKOnly, , ReportFilter
   
End Sub
deer87Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deer87Author Commented:
Currently using the code above to print Access report to pdf file based on distinct producer number but need to add additional vba code to print out each pdf file sent to the folder.
0
Jeffrey CoachmanMIS LiasonCommented:
Remember that the PDF output is theoretically the same as the Report itself, (In effect, ...A PDF stores the printer output codes to a file) ...so printing the report will be the same as printing the PDF.
So you can change this code:
 DoCmd.OpenReport "r_RDC_2015_DENTAL_SALES_BONUS", acViewReport, , "[Producer_Number]='" & temp & "'"

Open in new window

to:
 DoCmd.OpenReport "r_RDC_2015_DENTAL_SALES_BONUS", acViewNormal , , "[Producer_Number]='" & temp & "'"

Open in new window

...or simply add this "Print" line after (or before) the existing code to open/display the report...

This would be far simpler than creating code to loop the folder and print each PDF...

JeffCoachman
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
slubekCommented:
Execute Adobe Reader as external application with "/t" switch:
Sub Printpdf(Filename As String)
  Dim RetVal
  Dim Cmd As String

  Cmd = "c:\Program Files (x86)\Adobe\Reader 11.0\Reader\Acrord32.exe /t " & Filename
  RetVal = Shell(Cmd, 1)
End Sub

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

deer87Author Commented:
Excellent!!!
0
Jeffrey CoachmanMIS LiasonCommented:
glad I could help
0
deer87Author Commented:
Excellent!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.