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_B ONUS", acViewReport, , "[Producer_Number]='" & temp & "'"
DoCmd.OutputTo acOutputReport, "r_RDC_2015_DENTAL_SALES_B ONUS", acFormatPDF, mypath & "RDC_2015_DENTAL_SALES_BON US_" & MyFileName
DoCmd.Close acReport, "r_RDC_2015_DENTAL_SALES_B ONUS"
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
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\
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_B
DoCmd.OutputTo acOutputReport, "r_RDC_2015_DENTAL_SALES_B
DoCmd.Close acReport, "r_RDC_2015_DENTAL_SALES_B
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
ASKER
Excellent!!!
glad I could help
ASKER
Excellent!!
ASKER