Link to home
Start Free TrialLog in
Avatar of deer87
deer87

asked on

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
Avatar of deer87
deer87

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of deer87

ASKER

Excellent!!!
glad I could help
Avatar of deer87

ASKER

Excellent!!